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 818 B

123456789101112131415161718
  1. using Discord.Interactions;
  2. using Discord.WebSocket;
  3. using InteractionFramework.Attributes;
  4. using System.Threading.Tasks;
  5. namespace InteractionFramework
  6. {
  7. // As with all other modules, we create the context by defining what type of interaction this module is supposed to target.
  8. internal class ComponentModule : InteractionModuleBase<SocketInteractionContext<SocketMessageComponent>>
  9. {
  10. // 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: *.
  11. // See Attributes/DoUserCheckAttribute.cs for elaboration.
  12. [DoUserCheck]
  13. [ComponentInteraction("myButton:*")]
  14. public async Task ClickButtonAsync(string userId)
  15. => await RespondAsync(text: ":thumbsup: Clicked!");
  16. }
  17. }