From eaf8dee62f9fce8379a4a813240b00fe62d92e09 Mon Sep 17 00:00:00 2001 From: hydrabolt Date: Wed, 12 Aug 2015 16:37:06 +0100 Subject: [PATCH] small example fixes --- examples/formatting.js | 10 ++++++++-- examples/pingpong.js | 8 +++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/examples/formatting.js b/examples/formatting.js index 9131e9c37..02756eaaa 100644 --- a/examples/formatting.js +++ b/examples/formatting.js @@ -3,16 +3,22 @@ * messages is as simple as inserting the formatting codes into the message. */ -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 "$formatting". if ( message.content === "$formatting" ) { // Show off formatting by sending a simple message with formatting codes. - myBot.sendMessage( message.channel, "**bold** ****semibold**** *italic* " + + this.sendMessage( message.channel, "**bold** ****semibold**** *italic* " + "_**bold and italic**_ __underline__ ~~strikethrough~~" ); } } ); diff --git a/examples/pingpong.js b/examples/pingpong.js index 57d45dc42..800029288 100644 --- a/examples/pingpong.js +++ b/examples/pingpong.js @@ -5,7 +5,7 @@ * This bot responds to every "ping" message with a "pong". */ -var Discord = require( "discord.js" ); +var Discord = require( "../" ); // Create the bot var myBot = new Discord.Client(); @@ -13,6 +13,12 @@ var myBot = new Discord.Client(); // Login with an example email and password 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." ); +} ); + // Add a listener to the "message" event, which triggers upon receiving // any message myBot.on( "message", function( message ) {