Skip to content

Commit

Permalink
Add RequiredInput to example modal (#2348) - Misha-133
Browse files Browse the repository at this point in the history
  • Loading branch information
Misha-133 committed Aug 1, 2022
1 parent e0d68d4 commit ee6e0ad
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions docs/guides/int_framework/samples/intro/modal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ public class FoodModal : IModal
[ModalTextInput("food_name", placeholder: "Pizza", maxLength: 20)]
public string Food { get; set; }

// Additional paremeters can be specified to further customize the input.
// Additional paremeters can be specified to further customize the input.
// Parameters can be optional
[RequiredInput(false)]
[InputLabel("Why??")]
[ModalTextInput("food_reason", TextInputStyle.Paragraph, "Kuz it's tasty", maxLength: 500)]
public string Reason { get; set; }
Expand All @@ -22,10 +24,15 @@ public class FoodModal : IModal
[ModalInteraction("food_menu")]
public async Task ModalResponse(FoodModal modal)
{
// Check if "Why??" field is populated
string reason = string.IsNullOrWhiteSpace(modal.Reason)
? "."
: $" because {modal.Reason}";

// Build the message to send.
string message = "hey @everyone, I just learned " +
$"{Context.User.Mention}'s favorite food is " +
$"{modal.Food} because {modal.Reason}.";
$"{modal.Food}{reason}";

// Specify the AllowedMentions so we don't actually ping everyone.
AllowedMentions mentions = new();
Expand Down

0 comments on commit ee6e0ad

Please sign in to comment.