xxxxxxxxxx
client.on('message', message => {
if(message.content.startsWith(prefix + "ticket-message")) {
let btn1 = new disbut.MessageButton()
.setStyle('red')
.setEmoji(":ticket:")
.setID('1')
message.delete()
message.channel.send(`react here to open a ticket`, btn1)
}
})
client.on('clickButton', async (button) => {
await button.defer();
if(button.id === "1") {
let btn2 = new disbut.MessageButton()
.setLabel('close')
.setStyle('red')
.setEmoji(":x:")
.setID('2')
button.guild.channels.create(`${button.clicker.user.username} ticket`, {
permissionOverwrites: [
{
id: button.guild.roles.everyone,
deny: ['VIEW_CHANNEL'],
},
{
id: button.clicker.user.id,
allow: ['VIEW_CHANNEL'],
},
],
}).then(channel => {
channel.send(`**please wait for our support team \n react with the emoji to close the ticket**`, btn2)
})
}
if(button.id === "2") {
button.channel.send("deleting after 5 seconds")
setTimeout(function() {
button.channel.delete();
}, 5000)
}
})
xxxxxxxxxx
//Note that you need the Node module installed!
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);
xxxxxxxxxx
/*
Need more help? Add me on discord: Dwagon#0069
Discord.js ^13.8.1
*/
const { MessageButton, MessageActionRow } = require('discord.js');
const buttonVerify = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId('firstButton')
.setLabel('First Button')
.setStyle('PRIMARY')
.setDisabled(false), // Set it to "true" if you don't want people to be able to use the button at all
)
.addComponents(
new MessageButton()
.setCustomId('secondButton')
.setLabel('Second Button')
.setStyle('SECONDARY')
.setDisabled(false),
)
.addComponents(
new MessageButton()
.setCustomId('thirdButton')
.setLabel('Third Button')
.setStyle('SUCCESS')
.setDisabled(false),
)
.addComponents(
new MessageButton()
.setCustomId('fourthButton')
.setLabel('Fourth Button')
.setStyle('DANGER')
.setDisabled(false),
)
.addComponents(
new MessageButton()
.setLabel('Fifth Button')
.setURL("https://www.codegrepper.com/")
.setStyle('LINK')
.setDisabled(false),
);
/*
Button style
PRIMARY - Blue
SECONDARY - Gray
SUCCESS - Green
DANGER - Red
LINK - Cannot put a customId to it
*/
xxxxxxxxxx
const disbut = require('discord-buttons')(client); // you'll need this module along side discord.js
let YESbutton = new disbut.MessageButton() // button yes
.setStyle('green') // green color
// if .setStyle('url'), then .setURL('https://discord-buttons.js.org/')
.setLabel('yea') // yea text
.setID('yes') // button id. if style is url, ignore this, url buttons dont have id's
let nobutton = new disbut.MessageButton() // button no
.setStyle('red') // red color, there also exists blurple and gray
.setLabel('nah') // nah text
.setID('no') // button id
.setDisabled() // OPTIONAL
message.channel.send('did you guys subscribe to technoblade?', {
buttons: [YESbutton, nobutton]
})
client.on('clickButton', async (button) => {
// code here
// more examples at https://discord-buttons.js.org/
})