From 7fd5f8f5a66289dcd680d407e0caa954c4e968ee Mon Sep 17 00:00:00 2001 From: meew0 Date: Wed, 12 Aug 2015 14:03:21 +0200 Subject: [PATCH] Fix query.js to properly deal with users with spaces in their name. --- examples/query.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/query.js b/examples/query.js index 4cf7e7df1..00680102f 100644 --- a/examples/query.js +++ b/examples/query.js @@ -16,15 +16,15 @@ myBot.on( "message", function( message ) { var channel = message.channel; // Find all the arguments to the command. - var arguments = message.content.split(" "); + var arguments = message.content.split( " " ); // Get the first argument specifically, as it contains the username // to be queried for. - var username = arguments[1]; + var username = arguments.slice( 1 ).join( " " ); // Exit the event handler unless the user exists. if( !username ) { - myBot.sendMessage(channel, "That user doesn't exist!"); + myBot.sendMessage( channel, "That user doesn't exist!" ); return; } @@ -39,11 +39,11 @@ myBot.on( "message", function( message ) { // Only continue if the message has been found if( message ) { - myBot.sendMessage(channel, "The last message from user " + username + - " is: \"" + message.content + "\"."). + myBot.sendMessage( channel, "The last message from user " + username + + " is: \"" + message.content + "\"." ). } else { - myBot.sendMessage("That user has not sent a message " + - "for the last 100 messages!") + myBot.sendMessage( "That user has not sent a message " + + "for the last 100 messages!" ) } } ); }