discordjs / Commando

Official command framework for discord.js
Apache License 2.0
497 stars 243 forks source link

Slash commands support #387

Open ArnaudLier opened 3 years ago

ArnaudLier commented 3 years ago

It would be cool to integrate Slash commands support in Commando: https://discord.com/developers/docs/interactions/slash-commands. It can be done with something like this:


  client.registry.commands.forEach(command => {
    client.api.applications(client.user.id).guilds('GUILD ID').commands.post({
      data: {
        name: command.name.replace(/-/g, ''),
        description: command.description,
        options: command.argsCollector?.args.map(arg => ({
          name: arg.label.replace(/[\s/]/g, '-'),
          description: arg.prompt,
          type: getDiscordType(arg.type?.id),
          required: typeof arg.default === 'undefined',
        }))
      }
    })
  })

  client.ws.on('INTERACTION_CREATE', async interaction => {
    // console.log(interaction)
    // client.api.interactions(interaction.id, interaction.token).callback.post({
    //   data: {
    //     type: 4,
    //     data: {
    //       content: 'Hello world!'
    //     }
    //   }
    // })
  })```
AFink commented 3 years ago

That looks very nice :D, I think Commando will wait to implement this until the main lib has it integrated.. Anyway, you know a way to run the commando- commands in the INTERACTION_CREATE-event and return the message as a slash command callback?

thomasthebro1 commented 3 years ago

I definitely like the idea of this suggestion. Slash command support will add to Commando's wide range of fantastic features that it already has.

HugoFerrant commented 3 years ago

discordjs/discord.js has Slash Commands merged ! See this issue https://github.com/discordjs/discord.js/issues/5103 and the related PR https://github.com/discordjs/discord.js/pull/5448 :rocket: Looking forward to see this in Commando, sending some love to maintainer here (because there is no Sponsor link)!

MrJesseh commented 2 years ago

Would be nice to see slash command support with commando for sure.

dukeofsussex commented 2 years ago

Would be nice to see slash command support with commando for sure.

Try https://github.com/Snazzah/slash-create, inspired by Commando.