owengombas / discord.ts

🤖 Create your discord bot by using TypeScript and decorators!

Home Page:https://owencalvin.github.io/discord.ts/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support ButtonInteraction

Tenebrosful opened this issue · comments

Hi, this is a proposal to use MessageComponents like Buttons easier like Slash commands are easier with decorators.

I'm not a English native, sorry if some explanation are weird or something like that.

Proposal 1 - Split interaction event in two

For now interaction are handle like this

client.on("interaction", (interaction) => {
    client.executeSlash(interaction);
  });

But interaction can be CommandInteraction or ButtonInteraction.

I think it's could be nice to split this event in two like (feel free to change event's name)

client.on("interaction", (interaction) => {
   //Switch statement with interaction.type or things like that
  });

client.on("command", (interaction: CommandInteraction) => {
    client.executeSlash(interaction);
  });

client.on("button", (interaction: ButtonInteraction) => {
    client.executeButton(interaction);
  });

Proposal 2 - Create a decorator @Button('customID')

Like @slash, it could be nice to create a decorator to handle ButtonInterraction

@Discord()
abstract class ButtonExample{

    //param is customID, see https://discord.js.org/#/docs/main/master/class/ButtonInteraction?scrollTo=customID
    @Button('buttonExample-1')
    //@Guard(...)
    private buttonExample1(
        interaction: ButtonInteraction
    ) {
        //...
    }
}