Update Examples (closes #380) (#383)

* Update examples

* Forgot to save send-files
This commit is contained in:
Manuel Kraus
2016-05-29 03:55:39 +02:00
committed by abalabahaha
parent b9506d01ab
commit 8d64435def
9 changed files with 114 additions and 176 deletions

View File

@@ -1,5 +1,5 @@
/*
this bot is a ping pong bot, and every time a message
This bot is a ping pong bot, and every time a message
beginning with "ping" is sent, it will reply with
"pong!".
*/
@@ -12,12 +12,12 @@ var AuthDetails = require("./auth.json");
var bot = new Discord.Client();
//when the bot is ready
bot.on("ready", function () {
console.log("Ready to begin! Serving in " + bot.channels.length + " channels");
bot.on("ready", () => {
console.log(`Ready to begin! Serving in ${bot.channels.length} channels`);
});
//when the bot disconnects
bot.on("disconnected", function () {
bot.on("disconnected", () => {
//alert the console
console.log("Disconnected!");
@@ -26,15 +26,15 @@ bot.on("disconnected", function () {
});
//when the bot receives a message
bot.on("message", function (msg) {
bot.on("message", msg => {
//if message begins with "ping"
if (msg.content.indexOf("ping") === 0) {
if (msg.content.startsWith("ping")) {
//send a message to the channel the ping message was sent in.
bot.sendMessage(msg.channel, "pong!");
bot.sendMessage(msg, "pong!");
//alert the console
console.log("pong-ed " + msg.author.username);
}
});
bot.login(AuthDetails.email, AuthDetails.password);
bot.loginWithToken(AuthDetails.token);