You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

receiving-context-menu-command-events.md 1.3 KiB

Implemented Context Menus (#106) * Update README.md * Update README.md * Fix SocketSlashCommandDataOption to use long for Number instead of int (#89) * Application webhooks (#86) * Added webhook components for hooks having an application ID. * resolved #88 * resolved #85 * Update device for gateway * Fix MessageProperties.Embed being ignored in some methods that modifies a message (#92) * Update label/description lengths for selects (ref: https://github.com/discord/discord-api-docs/pull/3598/files) (#91) https://github.com/discord/discord-api-docs/pull/3598/files * Fix tests (#90) * Fix gateway serialization to include nulls (#96) * Add missing guild permissions (#93) * Update GuildPermissions.cs * Update GuildPermissionsTests.cs * Add banner and accent color to user and some fixes/improvements (#81) * Add banner and accent color to user and some fixes * Fix * Fix! * increase size of user banners to 256 * Some changes and mini refactor of color class * add constant maxDecimalValue to color and checks with exceptions * add `NotSupportedException` for `BannerId` and `AccentColor` in `SocketWebhookUser` * Update ComponentBuilder.cs - `MaxLabelLength` from `ComponentBuilder` moved to `ButtonBuilder` - Added `MaxLabelLength` for `SelectMenuOptionBuilder` - Changed `MaxDescriptionLength` to 100 * Interface Method Declarations for Interaction Methods (#99) * added interface method declarations * inline docs * Fix serialization error * meta: bump versions * Fix debug pragma * meta: bump version * Remove rich presence button * Assign CurrentUserId in Sharded Client (#100) * added interface method declarations * inline docs * current user id assignment in sharded client * Allow EmbedBuilder.ImageUrl to use attachment scheme syntax (#104) * Make Webhook ApplicationId nullable instead of optional + fix IDiscordInteraction DeferAsync method (#110) * Make Webhook ApplicationId nullable instead of optional * Fix IDiscordInteraction DeferAsync to account for ephemeral defer * Fix application command and thread starter messages being created as SocketSystemMessage * Added description of ApplicationCommandType Enums * Requested Fixes renamed SocketApplicationUserCommand to SocketUserCommand renamed SocketApplicationMessageCommand to SocketMessageCommand using ContextMenuCreationProperties for both User and Message commands * Added Summary to public members removed whitespace from DiscordRestApiClient.cs * Fixing guide to use switch statement * implemented TrySendApplicationCommandAsync * implemented ephemeral in SocketCommandBase Defer, and RespondAsync. assigning int 64 was error. changed to "MessageFlags.Ephemeral", built and tested to work. * removed ApplicationCommandType from SocketUser and SocketMessageCommandData Co-authored-by: Quin Lynch <49576606+quinchs@users.noreply.github.com> Co-authored-by: František Boháček <fandabohacek@gmail.com> Co-authored-by: quin lynch <lynchquin@gmail.com> Co-authored-by: d4n3436 <dan3436@hotmail.com> Co-authored-by: MrCakeSlayer <13650699+MrCakeSlayer@users.noreply.github.com> Co-authored-by: Nikon <47792796+INikonI@users.noreply.github.com> Co-authored-by: Cenk Ergen <57065323+Cenngo@users.noreply.github.com>
3 years ago
Implemented Context Menus (#106) * Update README.md * Update README.md * Fix SocketSlashCommandDataOption to use long for Number instead of int (#89) * Application webhooks (#86) * Added webhook components for hooks having an application ID. * resolved #88 * resolved #85 * Update device for gateway * Fix MessageProperties.Embed being ignored in some methods that modifies a message (#92) * Update label/description lengths for selects (ref: https://github.com/discord/discord-api-docs/pull/3598/files) (#91) https://github.com/discord/discord-api-docs/pull/3598/files * Fix tests (#90) * Fix gateway serialization to include nulls (#96) * Add missing guild permissions (#93) * Update GuildPermissions.cs * Update GuildPermissionsTests.cs * Add banner and accent color to user and some fixes/improvements (#81) * Add banner and accent color to user and some fixes * Fix * Fix! * increase size of user banners to 256 * Some changes and mini refactor of color class * add constant maxDecimalValue to color and checks with exceptions * add `NotSupportedException` for `BannerId` and `AccentColor` in `SocketWebhookUser` * Update ComponentBuilder.cs - `MaxLabelLength` from `ComponentBuilder` moved to `ButtonBuilder` - Added `MaxLabelLength` for `SelectMenuOptionBuilder` - Changed `MaxDescriptionLength` to 100 * Interface Method Declarations for Interaction Methods (#99) * added interface method declarations * inline docs * Fix serialization error * meta: bump versions * Fix debug pragma * meta: bump version * Remove rich presence button * Assign CurrentUserId in Sharded Client (#100) * added interface method declarations * inline docs * current user id assignment in sharded client * Allow EmbedBuilder.ImageUrl to use attachment scheme syntax (#104) * Make Webhook ApplicationId nullable instead of optional + fix IDiscordInteraction DeferAsync method (#110) * Make Webhook ApplicationId nullable instead of optional * Fix IDiscordInteraction DeferAsync to account for ephemeral defer * Fix application command and thread starter messages being created as SocketSystemMessage * Added description of ApplicationCommandType Enums * Requested Fixes renamed SocketApplicationUserCommand to SocketUserCommand renamed SocketApplicationMessageCommand to SocketMessageCommand using ContextMenuCreationProperties for both User and Message commands * Added Summary to public members removed whitespace from DiscordRestApiClient.cs * Fixing guide to use switch statement * implemented TrySendApplicationCommandAsync * implemented ephemeral in SocketCommandBase Defer, and RespondAsync. assigning int 64 was error. changed to "MessageFlags.Ephemeral", built and tested to work. * removed ApplicationCommandType from SocketUser and SocketMessageCommandData Co-authored-by: Quin Lynch <49576606+quinchs@users.noreply.github.com> Co-authored-by: František Boháček <fandabohacek@gmail.com> Co-authored-by: quin lynch <lynchquin@gmail.com> Co-authored-by: d4n3436 <dan3436@hotmail.com> Co-authored-by: MrCakeSlayer <13650699+MrCakeSlayer@users.noreply.github.com> Co-authored-by: Nikon <47792796+INikonI@users.noreply.github.com> Co-authored-by: Cenk Ergen <57065323+Cenngo@users.noreply.github.com>
3 years ago
12345678910111213141516171819202122232425262728293031323334353637383940
  1. # Receiving Context Menu events
  2. User commands and Message commands have their own unique objects returned. Different from Slash commands. To get the appropriate object returned, you can use a similar method to the slash commands.
  3. ```cs
  4. client.InteractionCreated += InteractionCreatedHandler;
  5. ...
  6. public async Task InteractionCreatedHandler(SocketInteraction arg)
  7. {
  8. if ( arg.Type == InteractionType.ApplicationCommand)
  9. Task.Run(() => ApplicationCommandHandler(arg));
  10. }
  11. public async Task ApplicationCommandHandler(SocketInteraction arg)
  12. {
  13. switch (arg)
  14. {
  15. case SocketSlashCommand slashCommand:
  16. Console.Writeline("Slash command received!");
  17. break;
  18. case SocketUserCommand userCommand:
  19. Console.Writeline("User command received!")
  20. // userCommand.User = User who ran command.
  21. // userCommand.Data.Member = User who was clicked.
  22. break;
  23. case SocketMessageCommand messageCommand:
  24. Console.Writeline("Message command received!")
  25. // messageCommand.User = User who ran command.
  26. // messageCommand.Data.Message = Message that was clicked.
  27. break;
  28. }
  29. }
  30. ```
  31. User commands return a SocketUser object, showing the user that was clicked to run the command.
  32. Message commands return a SocketMessage object, showing the message that was clicked to run the command.
  33. Both return the user who ran the command, the guild (if any), channel, etc.