You must send a message with buttons in order to receive events from them. There are 5 styles of buttons: Primary (Blurple), Secondary (Grey), Success (Green), Danger (Red), and Link, which are always grey. Link buttons do not send INTERACTION_CREATE
when pressed, but the rest do. The interaction type for buttons is 3
, so you can ignore slash commands by checking interaction.type
as shown below:
client.ws.on('INTERACTION_CREATE', async(interaction) =>
{
if (interaction.type != 3) return;
/* Do some stuff here. */
});
An example is the worker_thingy file, please ignore the errors, I made it at 2 am
and I'm using djs v13, or master branch, so you will likely need to install it with npm install discordjs/discord.js
.
1: Blurple
2: Grey
3: Green
4: Red
5: Link
Note: emoji
and label
are optional, but you must have one or the other. You can disable a button by adding "disabled": true
.
Type 6: Type 6 is DefferedMessageUpdate, and allows you to edit your message up to 15 minutes later. You can also make followup messages during this time.
Type 7: Type 7 is UpdateMessage. You must pass content to update your message with if you respond with type 7, where as type 6 is an empty body.
my bot with buttons
another bot with buttons but for F1 fans