// creating modal
var modalBuilder = new ModalBuilder()
.WithCustomId("modal.interaction")
.WithTitle($"Update something")
.AddTextInput("Name",
"modal.interaction.name",
TextInputStyle.Short,
"Name!",
1, 64, true);
await Context.Interaction.RespondWithModalAsync(modalBuilder.Build());
// IModal implementation for handling
public class UpdateModal : IModal
{
public string Title { get; } = "Update something";
[InputLabel("Name")]
[RequiredInput(true)]
[ModalTextInput(
"modal.interaction.name",
TextInputStyle.Short,
"Name!",
1,
64)]
public string Name { get; set; } = string.Empty;
}
// hanlding modal interaction
[ModalInteraction("modal.interaction")]
public async Task HandleUpdateModal(UpdateModal modal)
{
Console.WriteLine(modal.Name);
}
Why Modal doesn't implement IModal???
Is there a better way to handle modal interactions?