discord-buttons-pe
v1.0.3-beta
Published
Discord.js buttons
Downloads
10
Maintainers
Readme
This version is just discord-buttons but a little modified for my personnal use
Install
$ npm i discord-buttons
Setup
const discord = require('discord.js'); //Define the discord.js module
const client = new discord.Client(); //Creating discord.js client (constructor)
require('discord-buttons')(client); //Starting the discord-buttons class
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