From f49d87e63441e2199709ea2b5a78ff53b04e6c17 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Wed, 22 Mar 2017 00:37:11 +0000 Subject: [PATCH] Choose Changes --- commands/response/choose.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/commands/response/choose.js b/commands/response/choose.js index 83bc7e6e..477b7855 100644 --- a/commands/response/choose.js +++ b/commands/response/choose.js @@ -19,12 +19,13 @@ module.exports = class ChooseCommand extends commando.Command { if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } console.log("[Command] " + message.content); - if(message.content.includes("|")) { - let choice2 = message.content.split("|").slice(1).join(" "); - let choice1 = " " + message.content.replace(choice2, "").split(" ").slice(1).join(" "); - let coin = [choice1, choice2]; - coin = coin[Math.floor(Math.random() * coin.length)]; - message.channel.send("I choose" + coin.replace("|", "")); + if(message.content.includes(" | ")) { + let choices = message.content.split(" | "); + let choice1 = choices[0]; + let choice2 = choices[1]; + let randomChoice = [choice1, choice2]; + randomChoice = randomChoice[Math.floor(Math.random() * randomChoice.length)]; + message.channel.send("I choose " + randomChoice); } else { message.channel.send(":x: Split your two choices with a ' | '!"); }