small fixes and additions to examples, added deepFilter to list

This commit is contained in:
hydrabolt
2015-08-12 16:35:17 +01:00
parent 0013891764
commit 3e4f0fb74c
6 changed files with 96 additions and 43 deletions

View File

@@ -3,11 +3,17 @@
* access user avatars.
*/
var Discord = require( "discord.js" );
var Discord = require( "../" );
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." );
} );
myBot.on( "message", function( message ) {
// React to all messages with the content "$avatar"
if ( message.content === "$avatar" ) {
@@ -22,10 +28,10 @@ myBot.on( "message", function( message ) {
// A user can be mentioned in a message by inserting the string obtained
// by user.mention() into the message.
// Note that simply writing "@user" will NOT work.
bot.sendMessage( message.channel, message.author.mention() + ", here's your avatar: " + url );
this.sendMessage( message.channel, message.author.mention() + ", here's your avatar: " + url );
} else {
// Nothing should be done if the user has not set an avatar.
bot.sendMessage( message.channel, message.author.mention() + ", you don't have an avatar!" );
this.sendMessage( message.channel, message.author.mention() + ", you don't have an avatar!" );
}
}
} );