From 657b7b727d4ac1b45408eeba28d08f872d2815a7 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Tue, 25 Apr 2017 14:04:07 +0000 Subject: [PATCH] More Clean-Ups --- commands/games/lottery.js | 3 ++- commands/games/mathgame.js | 3 +-- commands/games/quiz.js | 3 +-- commands/games/typinggame.js | 3 +-- commands/guildinfo/emoji.js | 3 ++- commands/imageedit/meme.js | 3 ++- commands/random/math.js | 3 ++- commands/search/google.js | 1 + commands/search/neopet.js | 3 ++- package.json | 2 +- 10 files changed, 15 insertions(+), 12 deletions(-) diff --git a/commands/games/lottery.js b/commands/games/lottery.js index 52d41ef8..cd417577 100644 --- a/commands/games/lottery.js +++ b/commands/games/lottery.js @@ -12,7 +12,8 @@ module.exports = class LotteryCommand extends Command { run(message) { const lottery = Math.floor(Math.random() * 100) + 1; - if (lottery < 99) return message.say(`Nope, sorry ${message.author.username}, you lost.`); + if (lottery < 99) + return message.say(`Nope, sorry ${message.author.username}, you lost.`); return message.say(`Wow ${message.author.username}! You actually won! Great job!`); } }; diff --git a/commands/games/mathgame.js b/commands/games/mathgame.js index 09112837..af45f644 100644 --- a/commands/games/mathgame.js +++ b/commands/games/mathgame.js @@ -62,9 +62,8 @@ module.exports = class MathGameCommand extends Command { time: 10000, errors: ['time'] }); - if (collected.first().content !== solved.toString()) { + if (collected.first().content !== solved.toString()) return message.say(`Aw... Too bad, try again next time!\nThe correct answer is: ${solved}`); - } return message.say(`Good Job! You won! ${solved} is the correct answer!`); } catch (err) { return message.say(`Aw... Too bad, try again next time!\nThe correct answer is: ${solved}`); diff --git a/commands/games/quiz.js b/commands/games/quiz.js index b727c1e4..2f992467 100644 --- a/commands/games/quiz.js +++ b/commands/games/quiz.js @@ -34,9 +34,8 @@ module.exports = class QuizCommand extends Command { time: 15000, errors: ['time'] }); - if (collected.first().content.toLowerCase() !== answer) { + if (collected.first().content.toLowerCase() !== answer) return message.say(`The correct answer is: ${answer}`); - } return message.say(`Perfect! The correct answer is: ${answer}`); } catch (err) { return message.say(`Aw... Too bad, try again next time!\nThe Correct Answer was: ${answer}`); diff --git a/commands/games/typinggame.js b/commands/games/typinggame.js index 55a71138..c48d3d4e 100644 --- a/commands/games/typinggame.js +++ b/commands/games/typinggame.js @@ -63,9 +63,8 @@ module.exports = class TypingGameCommand extends Command { time: time, errors: ['time'] }); - if (collected.first().content !== sentence) { + if (collected.first().content !== sentence) return message.say('Nope, your sentence does not match the original. Try again next time!'); - } return message.say(`Good Job! You won!`); } catch (err) { return message.say('Aw... Too bad, try again next time!'); diff --git a/commands/guildinfo/emoji.js b/commands/guildinfo/emoji.js index f84e8d67..ae24b5ef 100644 --- a/commands/guildinfo/emoji.js +++ b/commands/guildinfo/emoji.js @@ -12,6 +12,7 @@ module.exports = class EmojiCommand extends Command { } run(message) { - return message.say(message.guild.emojis.map(e => e).join('')).catch(() => message.say(':x: Error! Perhaps you have no custom emoji?')); + return message.say(message.guild.emojis.map(e => e).join('')) + .catch(() => message.say(':x: Error! Perhaps you have no custom emoji?')); } }; diff --git a/commands/imageedit/meme.js b/commands/imageedit/meme.js index 9f0e4d90..44baa043 100644 --- a/commands/imageedit/meme.js +++ b/commands/imageedit/meme.js @@ -48,6 +48,7 @@ module.exports = class MemeCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) return message.say(':x: Error! I don\'t have the Attach Files Permission!'); const { type, toprow, bottomrow } = args; - return message.channel.send({files: [`https://memegen.link/${type}/${toprow}/${bottomrow}.jpg`]}); + return message.channel.send({files: [`https://memegen.link/${type}/${toprow}/${bottomrow}.jpg`]}) + .catch(() => message.say(':x: Error! Something went wrong!')); } }; diff --git a/commands/random/math.js b/commands/random/math.js index 465132a7..83b2f7de 100644 --- a/commands/random/math.js +++ b/commands/random/math.js @@ -20,7 +20,8 @@ module.exports = class MathCommand extends Command { const { expression } = args; try { const solved = math.eval(expression); - return message.say(solved).catch(() => message.say(':x: Error! Invalid statement!')); + return message.say(solved) + .catch(() => message.say(':x: Error! Invalid statement!')); } catch (err) { return message.say(':x: Error! Invalid statement!'); } diff --git a/commands/search/google.js b/commands/search/google.js index 760d7d80..66553128 100644 --- a/commands/search/google.js +++ b/commands/search/google.js @@ -27,6 +27,7 @@ module.exports = class GoogleCommand extends Command { .get(`https://www.google.com/search?q=${query}`); const $ = cheerio.load(text); let href = $('.r').first().find('a').first().attr('href'); + if (!href) throw new Error('No Results'); href = querystring.parse(href.replace('/url?', '')); return msg.edit(href.q); } catch (err) { diff --git a/commands/search/neopet.js b/commands/search/neopet.js index 40ac5c63..1aa7ca33 100644 --- a/commands/search/neopet.js +++ b/commands/search/neopet.js @@ -28,7 +28,8 @@ module.exports = class NeopetCommand extends Command { .get(`http://www.sunnyneo.com/petimagefinder.php?name=${pet}&size=5&mood=1`); const $ = cheerio.load(text); const link = $('textarea').first().text(); - if (!link.includes('cp')) return message.say(':x: Error! Pet not found!'); + if (!link.includes('cp')) + return message.say(':x: Error! Pet not found!'); return message.say(link); } catch (err) { return message.say(':x: Error! Something went wrong!'); diff --git a/package.json b/package.json index aa15ed14..f5cf900a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "32.0.4", + "version": "32.1.0", "description": "A Discord Bot", "main": "shardingmanager.js", "scripts": {