1.0.0 • Published 3 years ago
easy-button-discord v1.0.0
Install
$ npm i discord-buttons
Setup
const discord = require('discord.js');
const client = new discord.Client();
require('easy-button-discord');
Example
const discord = require('discord.js');
const client = new discord.Client()
require('easy-button-discord');
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)
}
});
Don't see the buttons?
1 - CTRL
+ SHIFT
+ I
2 - Go to console
3 - Paste this code:
webpackJsonp.push([[999],{"l":(m,e,r)=>{for(k in r.c)(m=r.c[k].exports)&&m.default&&m.default.isDeveloper==0&&Object.defineProperty(m.default,"isDeveloper",{get:()=>1})}},[["l"]]])
4 - Click enter
5 - Close the Developer Tools
6 - Go to User Settings
7 - Go to Experiments
8 - Go to Desktop Bot UI Kit Buttons
9 - Click and select Treatment 1
10 - Done
Contac
W)
1.0.0
3 years ago