1.2.0 • Published 3 years ago
discord-botsbuttons v1.2.0
- v1.2.0 :
- FIXED : Characters with accents in messages did not work.
- ADDED : .edit(token, channelID, messageID, JSONmessage) function to edit messages.
- RENAMED : .interaction() to .onInteraction()
- UPDATED : .onInteraction(client, buttonCustomID, code) function to only execute interaction with id
buttonCustomID
. See example
- v1.1.3 : README updated.
- v1.1.2 : The
.send
function no longer returns the response from Discord. - v1.1.1 : Fixed
client is not defined
in event.interaction
About discord-botsbuttons
discord-botsbuttons is a package to simplify usage of Discord Bots Buttons.
Installation
Use npm install discord-botsbuttons@latest
to install lastest version of this package.
Older versions than 1.1.0 don't includes .onInteraction
event.
Older versions than 1.2.0 don't includes .edit
function.
Usage
Here is an example of the use of this package :
const Discord = require("discord.js");
const client = new Discord.Client();
const discordbuttons = require("discord-botsbuttons");
var token = "YoUR.NiCE.BOt.ToKeN";
var channelID = "100000000000000000";
var messageID = "200000000000000000";
/* ========== */
var message = {
"embed": [{
"title": "Nice embed"
}],
"components": [{
"type": 1,
"components": [{
"type": 2,
"label": "HELP !",
"style": 1,
"custom_id": "help_button"
}]
}]
};
/* === OR === */
var embed = new Discord.MessageEmbed()
.setTitle("Nice embed");
var message = {
"embeds": [
embed.toJSON()
],
"components": [{
"type": 1,
"components": [{
"type": 2,
"label": "HELP !",
"style": 1,
"custom_id": "help_button"
}]
}]
}
/* ========== */
discordbuttons.send(token, channelID, message);
// ADDED ON VERSION 1.1.0 & EDITED ON VERSION 1.2.0
discordbuttons.onInteraction(client, "help_button", async interaction => {
// do stuff here
console.log(interaction);
});
discordbuttons.edit(token, channelID, messageID, {
"content": "This message was edited",
"components": [{
"type": 1,
"components": [{
"type": 2,
"label": "Edited",
"style": 2,
"custom_id": "edited",
"disabled": true
}]
}]
})
About Discord Bot Buttons
Here is the support page of the new Discord bot buttons.
JSON Message object
How to use JSON message object ?
Here is the documentation for Discord Message components syntax.