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.

README.md 2.6 kB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Discord.Net Labs
  2. This repo is a custom fork of Discord.Net that introduces the newest features of discord for testing and experimenting. Nothing here is guaranteed to work but you are more than welcome to submit bugs in the issues tabs
  3. ## Branches
  4. ### Dev
  5. The main branch we pull off of to introduce new features into, the dev branch is the same as Discord.Nets dev branch
  6. ### Interactions
  7. This branch is for anything todo with Discord Interactions, such as [Slash commands](https://discord.com/developers/docs/interactions/slash-commands) and [Message Components](https://discord.com/developers/docs/interactions/message-components). This branch is stable enough to use but does not contain all the features of interactions.
  8. ### SlashCommandService
  9. This branch is on pause and does not work currently, Once everything is stable with the Interaction branch we will continue working on a slash command service for it.
  10. ### web/SlashCommandService
  11. webmilio's spin on the SlashCommandService branch, again the state of this is unknown.
  12. ## Message Components
  13. So, you want to use Message components? Well you're in luck! Below is a quick overview of how to use them
  14. #### Listening for button presses
  15. ```cs
  16. // Subscribe to the InteractionCreated event
  17. client.InteractionCreated += Client_InteractionCreated;
  18. ...
  19. private async Task Client_InteractionCreated(SocketInteraction arg)
  20. {
  21. // If the type of the interaction is a message component
  22. if(arg.Type == Discord.InteractionType.MessageComponent)
  23. {
  24. // parse the args
  25. var parsedArg = (SocketMessageComponent)arg;
  26. // respond with the update message response type. This edits the original message if you have set AlwaysAcknowledgeInteractions to false.
  27. await parsedArg.RespondAsync($"Clicked {parsedArg.Data.CustomId}!", type: InteractionResponseType.UpdateMessage);
  28. }
  29. }
  30. ```
  31. #### Sending messages with buttons
  32. Theres a new field in all `SendMessageAsync` functions that takes in a `MessageComponent`, you can use it like so:
  33. ```cs
  34. var builder = new ComponentBuilder().WithButton("Hello!", ButtonStyle.Primary, customId: "id_1");
  35. await Context.Channel.SendMessageAsync("Test buttons!", component: builder.Build());
  36. ```
  37. ## Slash commands
  38. Slash command example how to's can be found [here](https://github.com/Discord-Net-Labs/Discord.Net-Labs/blob/Interactions/docs/guides/commands/application-commands.md). If you want to read some code using slash commands, you can do that [here](https://github.com/quinchs/SwissbotCore/blob/master/SwissbotCore/Handlers/AutoMod/Censor.cs)