From 2a1e3a7e69e24cdf2e54cbe2589247bf56ea57aa Mon Sep 17 00:00:00 2001 From: meew0 Date: Wed, 12 Aug 2015 13:24:42 +0200 Subject: [PATCH] Add comments to presence.js --- examples/presence.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/examples/presence.js b/examples/presence.js index ec8d9bc39..4a426e601 100644 --- a/examples/presence.js +++ b/examples/presence.js @@ -1,8 +1,18 @@ +/* + * A bot that shows how to listen to presence update events, such as a user + * joining or leaving. + */ + var Discord = require( "discord.js" ); var myBot = new Discord.Client(); myBot.login( "hello@example.com", "password1" ); +// The "presence" event is triggered when a user joins a server, leaves it or +// goes away. +// The status parameter can be "online", "offline" or "idle", respectively. myBot.on( "presence", function( user, status, server ) { + // Send a message on the default channel of the server, as presence updates + // are not restricted to one channel. bot.sendMessage( server.getDefaultChannel(), user.mention() + " is " + status + "!" ); } );