npm i discord-buttonsconst discord = require('discord.js'); //Define the discord.js module
const client = new discord.Client(); //Creating discord.js client (constructor)
const disbut = require('discord-buttons')(client);For more examples check our Documentation
let button = new disbut.MessageButton()
.setStyle('red') //default: blurple
.setLabel('My First Button!') //default: NO_LABEL_PROVIDED
.setID('click_to_function') //note: if you use the style "url" you must provide url using .setURL('https://example.com')
.setDisabled(); //disables the button | default: false
message.channel.send('Hey, i am powered by https://npmjs.com/discord-buttons', button);let button = new disbut.MessageButton()
.setURL('https://npmjs.com/discord-buttons') //note: if you use other styles it would be changes to 'url' automaticly (also removes 'id')
.setLabel('My First Button!') //default: NO_LABEL_PROVIDED
.setID('click_to_function') //note: if you use the style "url" you must provide url using .setURL('https://example.com')
.setDisabled(); //disables the button | default: false
message.channel.send('Hey, i am powered by https://npmjs.com/discord-buttons', button);let button = new disbut.MessageButton()
.setStyle('red') //default: blurple
.setLabel('My First Button!') //default: NO_LABEL_PROVIDED
.setID('click_to_function') //note: if you use the style "url" you must provide url using .setURL('https://example.com')
.setDisabled(); //disables the button | default: false
let button2 = new disbut.MessageButton()
.setStyle('url') //default: blurple
.setLabel('My Second Button!') //default: NO_LABEL_PROVIDED
.setURL('https://npmjs.com/discord-buttons') //note: if you use other style you must provide id using .setID('myid')
message.channel.send('Hey, i am powered by https://npmjs.com/discord-buttons', {
buttons: [
button, button2
]
});let myembed = new discord.MessageEmbed()
.setDescription('Hi!');
let btn = new disbut.MessageButton()
.setStyle('red') //default: blurple
.setLabel('My First Button!') //default: NO_LABEL_PROVIDED
.setID('click_to_function') //note: if you use the style "url" you must provide url using .setURL('https://example.com')
.setDisabled(); //disables the button | default: false
message.channel.send('Hey, i am powered by https://npmjs.com/discord-buttons', { button: btn, embed: myembed });const { MessageButton } = require('discord-buttons');
module.exports = {
name: 'test',
run: async (client, message, args) => {
let button = new MessageButton()
.setStyle('red') //default: blurple
.setLabel('My First Button!') //default: NO_LABEL_PROVIDED
.setID('click_to_function') //note: if you use the style "url" you must provide url using .setURL('https://example.com')
.setDisabled(); //disables the button | default: false
await message.channel.send('Hey, i am powered by https://npmjs.com/discord-buttons', button);
}
}client.on('clickButton', async (button) => {
if (button.id === 'click_to_function') {
button.channel.send(`${button.clicker.user.tag} clicked button!`);
}
});Checkout more examples on our docs
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

