mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
docs(WIP): Bring the main doc pages up to date, and add more examples (#2094)
* Bring some docs up to date, as well as add a new example * Missed an exclamation mark * Do requested changes * Do suggestions * Same suggestions for the other examples * Show people that they can also use reply with embeds * Typos in embed.js example * Remove object example from embeds, too complex Suggested by Yukine * Some changes, some requested changes * Add moderation examples! * Add attachment examples * Missing dot * Fix spacing * Requested Changes * Quote consistency * Tfw you break the syntax
This commit is contained in:
38
docs/examples/embed.js
Normal file
38
docs/examples/embed.js
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* 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');
|
||||
Reference in New Issue
Block a user