Implement Slash commands

Created by: Soyvolon

Summary

Implement slash commands as per Discord docs.

Details

  • Implement registering a command
  • Implement updating and deleting a command
    • A Cache for used commands? Code migrations? From what it seems, old commands would need to be manually removed from Discord, so if slash commands are used similarly to CommandsNext the library should handle when a change in code is made.
    • Updating a command can be done with the same POST request that a create uses, as Discord treats it as an upsert.
  • Receive information from the Gateway
  • Respond to Interactions (slash commands)
    • This needs to be over HTTP, it is not a command over the gateway (see here)
    • Handle followup messages and/or editing the original response.
  • Further endpoints would need to be added.

I haven't worked much on editing DSharpPlus, so correct me if I am wrong, but from Discord's Docs it seems a lot is different to handle slash commands than it is for regular bot commands. Would this be best as a new project, something like DSharpPlus.SlashCommands?

Edit 2020-12-17

Example Interaction from Discord when an interaction command is run: This command takes no additional attributes and is not a subcommand.

{
   "channel_id":"750486424901386330",
   "data":{
      "id":"789290437416189955",
      "name":"hello"
   },
   "guild_id":"750486424469372970",
   "id":"789298197872377876",
   "member":{
      "deaf":false,
      "is_pending":false,
      "joined_at":"2020-09-01T22:45:07.036000+00:00",
      "mute":false,
      "nick":null,
      "pending":false,
      "permissions":"2147483647",
      "premium_since":null,
      "roles":[
         
      ],
      "user":{
         "avatar":"27690e2da064e8bdb9c0cef91b2d3a46",
         "discriminator":"8016",
         "id":"133735496479145984",
         "public_flags":131200,
         "username":"Soyvolon"
      }
   },
   "token":"aW50ZXJhY3Rpb246Nzg5Mjk4MTk3ODcyMzc3ODc2OjdEWVNvQkI1OXExb21vYjRXRUc2SERtdjc0Nk1aZzBxa2d0dm9tTnpXb1ptUnZ4a2s0a20xVkhzVjdZUW13N1kyR2xBVzlYRmwzcDZ4MWc4eW81QmY2bm55ZTJOUmZIb1djSUw3MzFrZklZOE8wdjJwVzNreDNvS2RqTTlZSW9U",
   "type":2,
   "version":1
}

Edit 2020-12-24

  • Removed mention of bad DiscordMember values as @Neuheit latest branch Interaction Events does properly parse these values.