Deleted examples, beginning to write in EC6.

Examples and Hydrabot will soon live in a separate repo which is better
suited to learning - this is so the main package isn't bloated.
This commit is contained in:
hydrabolt
2015-08-23 16:55:23 +01:00
parent 16b007c635
commit 35b61312b9
40 changed files with 1830 additions and 2486 deletions

View File

@@ -1,37 +0,0 @@
/*
* A bot that shows how to mention users in messages and how to
* access user avatars.
*/
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" ) {
// Obtain the user who requested the avatar.
var user = message.author;
// Check whether the user actually has an avatar.
if ( user.avatar ) {
// Construct the avatar URL from the user ID and the avatar ID.
var url = "https://discordapp.com/api/users/" + user.id + "/avatars/" + user.avatar + ".jpg";
// 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.
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.
this.sendMessage( message.channel, message.author.mention() + ", you don't have an avatar!" );
}
}
} );