mirror of
https://github.com/danbulant/discord.js
synced 2026-05-20 12:59:08 +00:00
Add tonicdev support (#479)
* example file for tonicdev * add tonicdev to the package.json * meh
This commit is contained in:
parent
a102490b08
commit
babf550459
2 changed files with 33 additions and 1 deletions
31
examples/tonicdev.js
Normal file
31
examples/tonicdev.js
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
var Discord = require('discord.js');
|
||||
|
||||
const token = ''; // token for bot login
|
||||
|
||||
//when the bot is ready
|
||||
bot.on("ready", () => {
|
||||
console.log(`Ready to begin! Serving in ${bot.channels.length} channels`);
|
||||
});
|
||||
|
||||
//when the bot disconnects
|
||||
bot.on("disconnected", () => {
|
||||
//alert the console
|
||||
console.log("Disconnected!");
|
||||
|
||||
//exit node.js with an error
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
//when the bot receives a message
|
||||
bot.on("message", msg => {
|
||||
//if message begins with "ping"
|
||||
if (msg.content.startsWith("ping")) {
|
||||
//send a message to the channel the ping message was sent in.
|
||||
bot.sendMessage(msg, "pong!");
|
||||
|
||||
//alert the console
|
||||
console.log("pong-ed " + msg.author.username);
|
||||
}
|
||||
});
|
||||
|
||||
bot.loginWithToken(token);
|
||||
|
|
@ -49,5 +49,6 @@
|
|||
"browser": {
|
||||
"./src/Util/TokenCacher.js": "./src/Util/TokenCacher-shim.js",
|
||||
"./lib/Util/TokenCacher.js": "./lib/Util/TokenCacher-shim.js"
|
||||
}
|
||||
},
|
||||
"tonicExampleFilename": "./examples/tonicdev.js"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue