Install
$ npm i discord-buttons
Setup
const discord = require('discord.js');
const client = new discord.Client();
require('discord-buttons')(client);
Example
const discord = require('discord.js');
const client = new discord.Client();
require('discord-buttons')(client);
client.on('ready', () => console.log(client.user.tag));
client.on('message', message => {
if (message.content.startsWith('!button')) {
message.buttons('Hello World!', {
buttons: [
{
style: 'green',
label: 'Click to function!',
id: 'click_to_function'
},
{
style: 'url',
label: 'Vote for me!',
url: 'https://npmjs.com/top.gg-core'
}
]
})
}
})
client.login("TOKEN");
When button is clicked
client.on('clickButton', button => {
if (button.id === 'click_to_function') {
button.message.channel.send(button.clicker.user.tag)
}
});
Note: don't forgot to put require('discord-buttons')(client)
after your client
Documentation
Checkout more examples on our docs
Don't see the buttons?
The buttons are beta, so to see them you have to be a discord-tester or just wait for the update
For any questions or errors, join in our server and report the bug on the #errors channel https://discord.gg/5JtyYqW
Contact
Youtube, Discord