mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Update examples
This commit is contained in:
@@ -2,29 +2,29 @@
|
||||
A ping pong bot, whenever you send "ping", it replies "pong".
|
||||
*/
|
||||
|
||||
// import the discord.js module
|
||||
// Import the discord.js module
|
||||
const Discord = require('discord.js');
|
||||
|
||||
// create an instance of a Discord Client
|
||||
// Create an instance of a Discord Client
|
||||
const client = new Discord.Client();
|
||||
|
||||
// the token of your bot - https://discordapp.com/developers/applications/me
|
||||
// The token of your bot - https://discordapp.com/developers/applications/me
|
||||
const token = 'your bot token here';
|
||||
|
||||
// the ready event is vital, it means that your bot will only start reacting to information
|
||||
// from Discord _after_ ready is emitted.
|
||||
// The ready event is vital, it means that your bot will only start reacting to information
|
||||
// from Discord _after_ ready is emitted
|
||||
client.on('ready', () => {
|
||||
console.log('I am ready!');
|
||||
});
|
||||
|
||||
// create an event listener for messages
|
||||
// Create an event listener for messages
|
||||
client.on('message', message => {
|
||||
// if the message is "ping",
|
||||
// If the message is "ping"
|
||||
if (message.content === 'ping') {
|
||||
// send "pong" to the same channel.
|
||||
// Send "pong" to the same channel
|
||||
message.channel.send('pong');
|
||||
}
|
||||
});
|
||||
|
||||
// log our bot in
|
||||
// Log our bot in
|
||||
client.login(token);
|
||||
|
||||
Reference in New Issue
Block a user