using Discord.Interactions; using System; namespace Discord.Rest { public static class RestExtensions { /// /// Respond to an interaction with a . /// /// Type of the implementation. /// The interaction to respond to. /// The request options for this request. /// Serialized payload to be used to create a HTTP response. public static string RespondWithModal(this RestInteraction interaction, string customId, RequestOptions options = null, Action modifyModal = null) where T : class, IModal { if (!ModalUtils.TryGet(out var modalInfo)) throw new ArgumentException($"{typeof(T).FullName} isn't referenced by any registered Modal Interaction Command and doesn't have a cached {typeof(ModalInfo)}"); var modal = modalInfo.ToModal(customId, modifyModal); return interaction.RespondWithModal(modal, options); } } }