Update examples

This commit is contained in:
Crawl
2017-04-24 08:34:00 +02:00
parent b15e012788
commit bbb5d4c7a1
4 changed files with 36 additions and 35 deletions

View File

@@ -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);