Created
February 23, 2016 16:42
-
-
Save meew0/94dcd2c0f3c7a822c444 to your computer and use it in GitHub Desktop.
The ping pong example from discord.js, fixed up slightly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
this bot is a ping pong bot, and every time a message | |
beginning with "ping" is sent, it will reply with | |
"pong!". | |
*/ | |
// Load discord.js | |
var Discord = require("discord.js"); | |
// Create a client | |
var bot = new Discord.Client(); | |
// This code will run once the bot has started up. | |
bot.on("ready", function () { | |
console.log("Ready to begin! Serving in " + bot.channels.length + " channels"); | |
}); | |
// This code will run once the bot has disconnected from Discord. | |
bot.on("disconnected", function () { | |
// alert the console | |
console.log("Disconnected!"); | |
// exit node.js with an error | |
process.exit(1); | |
}); | |
// This code will run once the bot receives any message. | |
bot.on("message", function (msg) { | |
// if message begins with "ping" | |
if (msg.content.indexOf("ping") === 0) { | |
// send a message to the channel the ping message was sent in. | |
bot.sendMessage(msg.channel, "pong!"); | |
// alert the console | |
console.log("pong-ed " + msg.author.username); | |
} | |
}); | |
// Login (replace these auth details with your bot's) | |
bot.login("email@example.com", "hunter2"); |
@Porbei token
In the last Line bot.Login, dies it be email and bot client secret?
With the bot.login part at the end, what should I put in there? The bot client ID and token? Thanks for making this though!
You have to put bot.login("your bot's token");
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With the bot.login part at the end, what should I put in there? The bot client ID and token? Thanks for making this though!