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.

ComponentModule.cs 845 B

3 years ago
12345678910111213141516171819
  1. using Discord;
  2. using Discord.Interactions;
  3. using Discord.WebSocket;
  4. using InteractionFramework.Attributes;
  5. using System;
  6. using System.Threading.Tasks;
  7. namespace InteractionFramework
  8. {
  9. // As with all other modules, we create the context by defining what type of interaction this module is supposed to target.
  10. internal class ComponentModule : InteractionModuleBase<SocketInteractionContext<SocketMessageComponent>>
  11. {
  12. // With the Attribute DoUserCheck you can make sure that only the user this button targets can click it. This is defined by the first wildcard: *.
  13. // See Attributes/DoUserCheckAttribute.cs for elaboration.
  14. [DoUserCheck]
  15. [ComponentInteraction("myButton:*")]
  16. public async Task ClickButtonAsync(string userId)
  17. => await RespondAsync(text: ":thumbsup: Clicked!");
  18. }