Browse Source

Include addition vars for selection dropdowns

pull/1923/head
MrCakeSlayer GitHub 4 years ago
parent
commit
5e31eb12a6
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      README.md

+ 6
- 0
README.md View File

@@ -74,9 +74,15 @@ private async Task MyMessageComponentHandler(SocketInteraction arg)
// You can also followup with a second message
await parsedArg.FollowupAsync($"Clicked {parsedArg.Data.CustomId}!", type: InteractionResponseType.ChannelMessageWithSource, ephemeral: true);
//If you are using selection dropdowns, you can get the selected label and values using these:
var selectedLabel = ((SelectMenu) parsedArg.Message.Components.First().Components.First()).Options.FirstOrDefault(x => x.Value == parsedArg.Data.Values.FirstOrDefault())?.Label;
var selectedValue = parsedArg.Data.Values.First();
}
```

> Note: The example above assumes that the selection dropdown is expecting only 1 returned value, if you configured your dropdown for multiple values, you'll need to modify the code slightly.

### Sending messages with buttons
Theres a new field in all `SendMessageAsync` functions that takes in a `MessageComponent`, you can use it like so:
```cs


Loading…
Cancel
Save