mirror of
https://github.com/danbulant/discord.js
synced 2026-07-08 04:31:05 +00:00
Add an example that shows the bot status events
This commit is contained in:
parent
2a1e3a7e69
commit
d4cd1ec6f8
1 changed files with 24 additions and 0 deletions
24
examples/status.js
Normal file
24
examples/status.js
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* A bot that doesn't interact with Discord, but instead shows how to listen
|
||||||
|
* to the "ready" and "disconnected" events, that are triggered when the bot
|
||||||
|
* starts up or shuts down, respectively.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var Discord = require( "discord.js" );
|
||||||
|
var myBot = new Discord.Client();
|
||||||
|
|
||||||
|
myBot.login( "hello@example.com", "password1" );
|
||||||
|
|
||||||
|
// The "ready" event is triggered after the bot successfully connected to
|
||||||
|
// Discord and is ready to send messages.
|
||||||
|
myBot.on( "ready", function() {
|
||||||
|
console.log( "Bot connected successfully." );
|
||||||
|
} );
|
||||||
|
|
||||||
|
// The "disconnected" event is triggered after the connection to Discord
|
||||||
|
// ended.
|
||||||
|
// It is also triggered when the connection attempt fails, for example due
|
||||||
|
// to a wrong password.
|
||||||
|
myBot.on( "disconnected", function() {
|
||||||
|
console.log( "Bot disconnected from Discord." );
|
||||||
|
} );
|
||||||
Loading…
Reference in a new issue