discord.js-self
Version:
A fork of discord.js with support of user accounts
41 lines (34 loc) • 1.27 kB
JavaScript
;
/**
* An example of how you can send embeds
*/
// Extract the required classes from the discord.js module
const { Client, MessageEmbed } = require('discord.js');
// Create an instance of a Discord client
const client = new Client();
/**
* The ready event is vital, it means that only _after_ this will your bot start reacting to information
* received from Discord
*/
client.on('ready', () => {
console.log('I am ready!');
});
client.on('message', message => {
// If the message is "how to embed"
if (message.content === 'how to embed') {
// We can create embeds using the MessageEmbed constructor
// Read more about all that you can do with the constructor
// over at https://discord.js.org/#/docs/main/master/class/MessageEmbed
const embed = new MessageEmbed()
// Set the title of the field
.setTitle('A slick little embed')
// Set the color of the embed
.setColor(0xff0000)
// Set the main content of the embed
.setDescription('Hello, this is a slick embed!');
// Send the embed to the same channel as the message
message.channel.send(embed);
}
});
// Log our bot in using the token from https://discordapp.com/developers/applications/me
client.login('your token here');