mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
* chore: consistency/prettier * chore: rebase * chore: rebase * chore: include typings * fix: include typings file in prettier lint-staged
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
/**
|
|
* 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');
|