Install
$ npm i discord-buttons
Setup
const discord = require('discord.js');
const client = new discord.Client();
require('discord-buttons');
Example
const discord = require('discord.js');
const client = new discord.Client()
require('discord-buttons');
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");
Embed
if (message.content.startsWith('!embed')) {
let embed = new discord.MessageEmbed()
.setAuthor('Oh, hey!');
message.buttons('Hello World!', {
buttons: [
{
style: 'green',
label: 'Click to function!',
id: 'click_to_function'
}
],
embed: embed
})
}
When button is clicked
client.on('clickButton', button => {
if (button.id === 'click_to_function') {
button.message.channel.send(button.clicker.user.tag)
}
});
Found errors? DM me Angelo II#0007
Contact
Youtube, Discord