From 71809ed1097588221a73b4bdc70078992627cdbf Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Tue, 12 Feb 2019 02:03:56 +0530 Subject: [PATCH] Don't reply if no question exists --- commands/index.js | 20 ++++++++++---------- commands/is.js | 13 +++++++++---- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/commands/index.js b/commands/index.js index 6054f12..b9ad612 100644 --- a/commands/index.js +++ b/commands/index.js @@ -12,16 +12,16 @@ module.exports = (bot, [ questions, kys, insults, commands_list ]) => { bot.command("kys", (ctx) => ctx.reply(insults_fun(random, kys, default_text("kys", "kill"))(ctx))); bot.command("commands", (ctx) => ctx.reply(commands_list.join("\n"))); - bot.command("is", (ctx) => ctx.reply(is(random))); - bot.command("are", (ctx) => ctx.reply(is(random))); - bot.command("can", (ctx) => ctx.reply(is(random))); - bot.command("will", (ctx) => ctx.reply(is(random))); - bot.command("shall", (ctx) => ctx.reply(is(random))); - bot.command("was", (ctx) => ctx.reply(is(random))); - bot.command("do", (ctx) => ctx.reply(is(random))); - bot.command("does", (ctx) => ctx.reply(is(random))); - bot.command("did", (ctx) => ctx.reply(is(random))); - bot.command("should", (ctx) => ctx.reply(is(random))); + bot.command("is", (ctx) => ctx.reply(is(random)(ctx))); + bot.command("are", (ctx) => ctx.reply(is(random)(ctx))); + bot.command("can", (ctx) => ctx.reply(is(random)(ctx))); + bot.command("will", (ctx) => ctx.reply(is(random)(ctx))); + bot.command("shall", (ctx) => ctx.reply(is(random)(ctx))); + bot.command("was", (ctx) => ctx.reply(is(random)(ctx))); + bot.command("do", (ctx) => ctx.reply(is(random)(ctx))); + bot.command("does", (ctx) => ctx.reply(is(random)(ctx))); + bot.command("did", (ctx) => ctx.reply(is(random)(ctx))); + bot.command("should", (ctx) => ctx.reply(is(random)(ctx))); bot.command("coin", (ctx) => ctx.reply(random(["Heads", "Tails"])())); }; diff --git a/commands/is.js b/commands/is.js index 849e587..757e1de 100644 --- a/commands/is.js +++ b/commands/is.js @@ -1,7 +1,12 @@ -module.exports = (random) => - random([["Yes", "Yep", "Yeah", "Yus", "Ja", "Ya", "Aye", "Ay", "Oui"], +module.exports = (random) => (ctx) => +{ + + const text_array = ctx.message.text.split(" "); + if (text_array.length == 1) + return "You know, you also have to ask the question."; + + return random([["Yes", "Yep", "Yeah", "Yus", "Ja", "Ya", "Aye", "Ay", "Oui"], ["No", "Nopes", "Nu", "Nah", "Nein", "Naw", "Nay", "Yesn't"]][Math.round( Math.random())])(); - - +};