diff --git a/commands/avataredit/3000years.js b/commands/avataredit/3000years.js index d18d76a7..cd90af9c 100644 --- a/commands/avataredit/3000years.js +++ b/commands/avataredit/3000years.js @@ -35,7 +35,7 @@ module.exports = class YearsCommand extends Command { avatar.resize(200, 200); az.composite(avatar, 461, 127); az.getBuffer(Jimp.MIME_PNG, (err, buff) => { - if(err) return msg.say('An Unknown Error Occurred.'); + if(err) return msg.say(`An Error Occurred: ${err}`); return msg.channel.send({ files: [{ attachment: buff, name: 'az.png' }] }) .catch(err => msg.say(`An Error Occurred: ${err}`)); }); diff --git a/commands/avataredit/beautiful.js b/commands/avataredit/beautiful.js index 1b2c17e6..1fa0f973 100644 --- a/commands/avataredit/beautiful.js +++ b/commands/avataredit/beautiful.js @@ -36,7 +36,7 @@ module.exports = class BeautifulCommand extends Command { grunkle.composite(avatar, 341, 35); grunkle.composite(avatar, 342, 301); grunkle.getBuffer(Jimp.MIME_PNG, (err, buff) => { - if(err) return msg.say('An Unknown Error Occurred.'); + if(err) return msg.say(`An Error Occurred: ${err}`); return msg.channel.send({ files: [{ attachment: buff, name: 'beautiful.png' }] }) .catch(err => msg.say(`An Error Occurred: ${err}`)); }); diff --git a/commands/avataredit/bobross.js b/commands/avataredit/bobross.js index ecc64172..c9572ec6 100644 --- a/commands/avataredit/bobross.js +++ b/commands/avataredit/bobross.js @@ -38,7 +38,7 @@ module.exports = class BobRossCommand extends Command { blank.composite(avatar, 44, 85); blank.composite(bob, 0, 0); blank.getBuffer(Jimp.MIME_PNG, (err, buff) => { - if(err) return msg.say('An Unknown Error Occurred.'); + if(err) return msg.say(`An Error Occurred: ${err}`); return msg.channel.send({ files: [{ attachment: buff, name: 'bobross.png' }] }) .catch(err => msg.say(`An Error Occurred: ${err}`)); }); diff --git a/commands/avataredit/greyscale.js b/commands/avataredit/greyscale.js index a598ba5f..a81400db 100644 --- a/commands/avataredit/greyscale.js +++ b/commands/avataredit/greyscale.js @@ -28,7 +28,7 @@ module.exports = class GreyscaleCommand extends Command { const avatar = await Jimp.read(avatarURL); avatar.greyscale(); avatar.getBuffer(Jimp.MIME_PNG, (err, buff) => { - if(err) return msg.say('An Unknown Error Occurred.'); + if(err) return msg.say(`An Error Occurred: ${err}`); return msg.channel.send({ files: [{ attachment: buff, name: 'greyscale.png' }] }) .catch(err => msg.say(`An Error Occurred: ${err}`)); }); diff --git a/commands/avataredit/invert.js b/commands/avataredit/invert.js index d38b981d..e362401a 100644 --- a/commands/avataredit/invert.js +++ b/commands/avataredit/invert.js @@ -28,7 +28,7 @@ module.exports = class InvertCommand extends Command { const avatar = await Jimp.read(avatarURL); avatar.invert(); avatar.getBuffer(Jimp.MIME_PNG, (err, buff) => { - if(err) return msg.say('An Unknown Error Occurred.'); + if(err) return msg.say(`An Error Occurred: ${err}`); return msg.channel.send({ files: [{ attachment: buff, name: 'invert.png' }] }) .catch(err => msg.say(`An Error Occurred: ${err}`)); }); diff --git a/commands/avataredit/rip.js b/commands/avataredit/rip.js index bb5a15b1..b22a2f44 100644 --- a/commands/avataredit/rip.js +++ b/commands/avataredit/rip.js @@ -37,7 +37,7 @@ module.exports = class RIPCommand extends Command { avatar.resize(200, 200); grave.composite(avatar, 158, 51); grave.getBuffer(Jimp.MIME_PNG, (err, buff) => { - if(err) return msg.say('An Unknown Error Occurred.'); + if(err) return msg.say(`An Error Occurred: ${err}`); return msg.channel.send({ files: [{ attachment: buff, name: 'rip.png' }] }) .catch(err => msg.say(`An Error Occurred: ${err}`)); }); diff --git a/commands/avataredit/steamcard.js b/commands/avataredit/steamcard.js index 1d1e933e..93387511 100644 --- a/commands/avataredit/steamcard.js +++ b/commands/avataredit/steamcard.js @@ -40,7 +40,7 @@ module.exports = class SteamCardCommand extends Command { blank.composite(card, 0, 0); blank.print(font, 38, 20, username); blank.getBuffer(Jimp.MIME_PNG, (err, buff) => { - if(err) return msg.say('An Unknown Error Occurred.'); + if(err) return msg.say(`An Error Occurred: ${err}`); return msg.channel.send({ files: [{ attachment: buff, name: 'steamcard.png' }] }) .catch(err => msg.say(`An Error Occurred: ${err}`)); }); diff --git a/commands/avataredit/triggered.js b/commands/avataredit/triggered.js index 19d345b0..6dc7fac7 100644 --- a/commands/avataredit/triggered.js +++ b/commands/avataredit/triggered.js @@ -34,7 +34,7 @@ module.exports = class TriggeredCommand extends Command { blank.composite(avatar, 0, 0); blank.composite(triggered, 0, 0); blank.getBuffer(Jimp.MIME_PNG, (err, buff) => { - if(err) return msg.say('An Unknown Error Occurred.'); + if(err) return msg.say(`An Error Occurred: ${err}`); return msg.channel.send({ files: [{ attachment: buff, name: 'triggered.png' }] }) .catch(err => msg.say(`An Error Occurred: ${err}`)); }); diff --git a/commands/avataredit/wanted.js b/commands/avataredit/wanted.js index 637eedbb..349e067e 100644 --- a/commands/avataredit/wanted.js +++ b/commands/avataredit/wanted.js @@ -32,7 +32,7 @@ module.exports = class WantedCommand extends Command { avatar.resize(500, 500); wanted.composite(avatar, 189, 438); wanted.getBuffer(Jimp.MIME_PNG, (err, buff) => { - if(err) return msg.say('An Unknown Error Occurred.'); + if(err) return msg.say(`An Error Occurred: ${err}`); return msg.channel.send({ files: [{ attachment: buff, name: 'wanted.png' }] }) .catch(err => msg.say(`An Error Occurred: ${err}`)); }); diff --git a/commands/games/mathgame.js b/commands/games/mathgame.js index 1d464834..ecc7b08a 100644 --- a/commands/games/mathgame.js +++ b/commands/games/mathgame.js @@ -1,6 +1,5 @@ const { Command } = require('discord.js-commando'); const { RichEmbed } = require('discord.js'); -const { stripIndents } = require('common-tags'); const math = require('mathjs'); const operations = ['+', '-', '*']; @@ -14,12 +13,11 @@ module.exports = class MathGameCommand extends Command { args: [ { key: 'difficulty', - prompt: 'What should the difficulty of the math game be? `Easy`, `Medium`, `Hard`, `Extreme`, or `Impossible`?', + prompt: 'What should the difficulty of the game be? `Easy`, `Medium`, `Hard`, `Extreme`, or `Impossible`?', type: 'string', validate: difficulty => { - if(['easy', 'medium', 'hard', 'extreme', 'impossible'].includes(difficulty.toLowerCase())) - return true; - return 'Please set the difficulty to either `easy`, `medium`, `hard`, `extreme`, or `impossible`.'; + if(['easy', 'medium', 'hard', 'extreme', 'impossible'].includes(difficulty.toLowerCase())) return true; + return 'The difficulty must be either `easy`, `medium`, `hard`, `extreme`, or `impossible`.'; }, parse: difficulty => difficulty.toLowerCase() } @@ -64,16 +62,10 @@ module.exports = class MathGameCommand extends Command { errors: ['time'] }); if(collected.first().content !== solved) - return msg.say(stripIndents` - Aw... Too bad, try again next time! - The correct answer is: ${solved} - `); - return msg.say(`Good Job! You won! ${solved} is the correct answer!`); + return msg.say(`Nope! The correct answer is: ${solved}.`); + return msg.say(`Perfect! ${solved} is the correct answer!`); } catch(err) { - return msg.say(stripIndents` - Aw... Too bad, try again next time! - The correct answer is: ${solved} - `); + return msg.say(`Time! The correct answer is ${solved}.`); } } }; diff --git a/commands/games/quiz.js b/commands/games/quiz.js index 517d64dc..2065c21b 100644 --- a/commands/games/quiz.js +++ b/commands/games/quiz.js @@ -38,16 +38,13 @@ module.exports = class QuizCommand extends Command { errors: ['time'] }); if(collected.first().content.toLowerCase() !== answer) - return msg.say(`The correct answer is: ${answer}`); - return msg.say(`Perfect! The correct answer is: ${answer}`); + return msg.say(`The correct answer is: ${answer}.`); + return msg.say(`Perfect! The correct answer is: ${answer}.`); } catch(err) { - return msg.say(stripIndents` - Aw... Too bad, try again next time! - The Correct Answer was: ${answer} - `); + return msg.say(`Time! The correct answer is: ${answer}`); } } catch(err) { - return msg.say('An Unknown Error Occurred.'); + return msg.say(`An Error Occurred: ${err}.`); } } }; diff --git a/commands/games/rockpaperscissors.js b/commands/games/rockpaperscissors.js index 60a87312..5e69a1b3 100644 --- a/commands/games/rockpaperscissors.js +++ b/commands/games/rockpaperscissors.js @@ -17,8 +17,7 @@ module.exports = class RockPaperScissorsCommand extends Command { prompt: '`Rock`, `Paper`, or `Scissors`?', type: 'string', validate: choice => { - if(['rock', 'paper', 'scissors'].includes(choice.toLowerCase())) - return true; + if(['rock', 'paper', 'scissors'].includes(choice.toLowerCase())) return true; return 'Please enter either `rock`, `paper`, or `scissors`.'; }, parse: choice => choice.toLowerCase() diff --git a/commands/games/typinggame.js b/commands/games/typinggame.js index f821930c..8c54ddfd 100644 --- a/commands/games/typinggame.js +++ b/commands/games/typinggame.js @@ -12,12 +12,11 @@ module.exports = class TypingGameCommand extends Command { args: [ { key: 'difficulty', - prompt: 'What should the difficulty of the typing game be? `Easy`, `Medium`, `Hard`, `Extreme`, or `Impossible`?', + prompt: 'What should the difficulty of the game be? `Easy`, `Medium`, `Hard`, `Extreme`, or `Impossible`?', type: 'string', validate: difficulty => { - if(['easy', 'medium', 'hard', 'extreme', 'impossible'].includes(difficulty.toLowerCase())) - return true; - return 'Please set the difficulty to either `easy`, `medium`, `hard`, `extreme`, or `impossible`.'; + if(['easy', 'medium', 'hard', 'extreme', 'impossible'].includes(difficulty.toLowerCase())) return true; + return 'The difficulty must be either `easy`, `medium`, `hard`, `extreme`, or `impossible`.'; }, parse: difficulty => difficulty.toLowerCase() } @@ -63,7 +62,7 @@ module.exports = class TypingGameCommand extends Command { return msg.say('Nope, your sentence does not match the original. Try again next time!'); return msg.say(`Good Job! You won!`); } catch(err) { - return msg.say('Aw... Too bad, try again next time!'); + return msg.say('Time! Try again next time!'); } } }; diff --git a/commands/imageedit/meme.js b/commands/imageedit/meme.js index 5457a8f9..776b1eaa 100644 --- a/commands/imageedit/meme.js +++ b/commands/imageedit/meme.js @@ -15,9 +15,8 @@ module.exports = class MemeCommand extends Command { prompt: 'What meme type do you want to use?', type: 'string', validate: type => { - if(codes.includes(type.toLowerCase())) - return true; - return `${type.toLowerCase()} is not a valid meme type. Use \`help meme\` to view a list of types.`; + if(codes.includes(type.toLowerCase())) return true; + return 'Invalid meme type. Use `help meme` to view a list of meme types.'; }, parse: type => type.toLowerCase() }, @@ -25,23 +24,13 @@ module.exports = class MemeCommand extends Command { key: 'top', prompt: 'What should the top row of the meme to be?', type: 'string', - validate: top => { - if(/[a-zA-Z0-9.,!?'\s]+$/g.test(top) && top.length < 100) - return true; - return `Please do not use special characters and keep the rows under 100 characters each, top row has ${top.length}.`; - }, - parse: top => top.replace(/[ ]/g, '-').replace(/[?]/g, '~q') + parse: top => encodeURIComponent(top.replace(/[ ]/g, '-')) }, { key: 'bottom', prompt: 'What should the bottom row of the meme to be?', type: 'string', - validate: bottom => { - if(/[a-zA-Z0-9.,!?'\s]+$/g.test(bottom) && bottom.length < 100) - return true; - return `Please do not use special characters and keep the rows under 100 characters each, bottom row has ${bottom.length}.`; - }, - parse: bottom => bottom.replace(/[ ]/g, '-').replace(/[?]/g, '~q') + parse: bottom => encodeURIComponent(bottom.replace(/[ ]/g, '-')) } ] }); diff --git a/commands/moderation/ban.js b/commands/moderation/ban.js index a5165f93..26eb17bb 100644 --- a/commands/moderation/ban.js +++ b/commands/moderation/ban.js @@ -11,7 +11,7 @@ module.exports = class BanCommand extends Command { ], group: 'moderation', memberName: 'ban', - description: 'Bans a user and logs the ban to the mod_logs.', + description: 'Bans a user and logs the ban to the mod logs.', guildOnly: true, args: [ { @@ -24,9 +24,8 @@ module.exports = class BanCommand extends Command { prompt: 'What do you want to set the reason as?', type: 'string', validate: reason => { - if(reason.length < 140) - return true; - return `Please keep your reason under 140 characters, you have ${reason.length}.`; + if(reason.length < 140) return true; + return 'Invalid Reason. Reason must be under 140 characters.'; } } ] @@ -55,7 +54,7 @@ module.exports = class BanCommand extends Command { Reason: ${reason}. `); } catch(err) { - await msg.say('Failed to send DM to user.'); + await msg.say('Failed to send DM to the user.'); } await member.ban({ days: 7, reason }); await msg.say(':ok_hand:'); @@ -70,7 +69,7 @@ module.exports = class BanCommand extends Command { `); return modlogs.send({ embed }); } catch(err) { - return msg.say('An Unknown Error Occurred.'); + return msg.say(`An Error Occurred: ${err}`); } } }; diff --git a/commands/moderation/kick.js b/commands/moderation/kick.js index 95c2b733..0a27dd12 100644 --- a/commands/moderation/kick.js +++ b/commands/moderation/kick.js @@ -8,7 +8,7 @@ module.exports = class KickCommand extends Command { name: 'kick', group: 'moderation', memberName: 'kick', - description: 'Kicks a user and logs the kick to the mod_logs.', + description: 'Kicks a user and logs the kick to the mod logs.', guildOnly: true, args: [ { @@ -21,9 +21,8 @@ module.exports = class KickCommand extends Command { prompt: 'What do you want to set the reason as?', type: 'string', validate: reason => { - if(reason.length < 140) - return true; - return `Please keep your reason under 140 characters, you have ${reason.length}.`; + if(reason.length < 140) return true; + return 'Invalid Reason. Reason must be under 140 characters.'; } } ] @@ -67,7 +66,7 @@ module.exports = class KickCommand extends Command { `); return modlogs.send({ embed }); } catch(err) { - return msg.say('An Unknown Error Occurred.'); + return msg.say(`An Error Occurred: ${err}`); } } }; diff --git a/commands/moderation/lockdown.js b/commands/moderation/lockdown.js index c4a85e4b..d08373fd 100644 --- a/commands/moderation/lockdown.js +++ b/commands/moderation/lockdown.js @@ -15,8 +15,7 @@ module.exports = class LockdownCommand extends Command { prompt: 'Please enter either `start` or `stop`.', type: 'string', validate: type => { - if(['start', 'stop'].includes(type.toLowerCase())) - return true; + if(['start', 'stop'].includes(type.toLowerCase())) return true; return 'Please enter either `start` or `stop`.'; }, parse: type => type.toLowerCase() @@ -38,17 +37,17 @@ module.exports = class LockdownCommand extends Command { await msg.channel.overwritePermissions(msg.guild.defaultRole, { SEND_MESSAGES: false }); return msg.say(stripIndents` Lockdown Started, users without Administrator can no longer post messages. - Please use \`;lockdown stop\` to end the lockdown. + Please use \`lockdown stop\` to end the lockdown. `); } catch(err) { - return msg.say('Something went wrong!'); + return msg.say(`An Error Occurred: ${err}`); } } else if(type === 'stop') { try { await msg.channel.overwritePermissions(msg.guild.defaultRole, { SEND_MESSAGES: true }); return msg.say('Lockdown Ended, users without Administrator can now post messages.'); } catch(err) { - return msg.say('An Unknown Error Occurred.'); + return msg.say(`An Error Occurred: ${err}`); } } } diff --git a/commands/moderation/prune.js b/commands/moderation/prune.js index 43c8062b..b0301784 100644 --- a/commands/moderation/prune.js +++ b/commands/moderation/prune.js @@ -19,9 +19,8 @@ module.exports = class PruneCommand extends Command { prompt: 'How many messages do you want to delete? Limit of up to 99.', type: 'integer', validate: count => { - if(count < 100 && count > 0) - return true; - return `${count} is not a valid amount of messages. Limit 1-99.`; + if(count < 100 && count > 0) return true; + return 'Invalid Count. Count must be from 1-99.'; } } ] diff --git a/commands/moderation/softban.js b/commands/moderation/softban.js index c7dc2fbe..d894e902 100644 --- a/commands/moderation/softban.js +++ b/commands/moderation/softban.js @@ -8,7 +8,7 @@ module.exports = class SoftbanCommand extends Command { name: 'softban', group: 'moderation', memberName: 'softban', - description: 'Kicks a user and deletes their messages, and logs the softban to the mod_logs.', + description: 'Kicks a user and deletes their messages, and logs the softban to the mod logs.', guildOnly: true, args: [ { @@ -21,9 +21,8 @@ module.exports = class SoftbanCommand extends Command { prompt: 'What do you want to set the reason as?', type: 'string', validate: reason => { - if(reason.length < 140) - return true; - return `Please keep your reason under 140 characters, you have ${reason.length}.`; + if(reason.length < 140) return true; + return 'Invalid Reason. Reason must be under 140 characters.'; } } ] @@ -70,7 +69,7 @@ module.exports = class SoftbanCommand extends Command { `); return modlogs.send({ embed }); } catch(err) { - return msg.say('An Unknown Error Occurred.'); + return msg.say(`An Error Occurred: ${err}`); } } }; diff --git a/commands/moderation/unban.js b/commands/moderation/unban.js index e3191b36..d8aa1238 100644 --- a/commands/moderation/unban.js +++ b/commands/moderation/unban.js @@ -11,7 +11,7 @@ module.exports = class UnbanCommand extends Command { ], group: 'moderation', memberName: 'unban', - description: 'Unbans a user and logs the unban to the mod_logs.', + description: 'Unbans a user and logs the unban to the mod logs.', guildOnly: true, args: [ { @@ -19,9 +19,8 @@ module.exports = class UnbanCommand extends Command { prompt: 'What member do you want to unban? Please enter the ID of the user.', type: 'string', validate: id => { - if(id.length === 18) - return true; - return `${id} is not a valid ID. Please enter the user you wish to unban's ID.`; + if(id.length === 18) return true; + return 'Invalid ID.'; } }, { @@ -29,9 +28,8 @@ module.exports = class UnbanCommand extends Command { prompt: 'What do you want to set the reason as?', type: 'string', validate: reason => { - if(reason.length < 140) - return true; - return `Please keep your reason under 140 characters, you have ${reason.length}.`; + if(reason.length < 140) return true; + return 'Invalid Reason. Reason must be under 140 characters.'; } } ] @@ -45,7 +43,7 @@ module.exports = class UnbanCommand extends Command { async run(msg, args) { if(!msg.channel.permissionsFor(this.client.user).has('BAN_MEMBERS')) return msg.say('This Command requires the `Ban Members` Permission.'); - const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog', 'mod_logs')); + const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog')); if(!modlogs) return msg.say('This Command requires a channel set with the `modchannel` command.'); if(!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) @@ -69,7 +67,7 @@ module.exports = class UnbanCommand extends Command { `); return modlogs.send({ embed }); } catch(err) { - return msg.say('An Unknown Error Occurred.'); + return msg.say(`An Error Occurred: ${err}`); } } }; diff --git a/commands/moderation/warn.js b/commands/moderation/warn.js index 4b809cbd..d8d56ac3 100644 --- a/commands/moderation/warn.js +++ b/commands/moderation/warn.js @@ -8,7 +8,7 @@ module.exports = class WarnCommand extends Command { name: 'warn', group: 'moderation', memberName: 'warn', - description: 'Warns a user and logs the warn to the mod_logs.', + description: 'Warns a user and logs the warn to the mod logs.', guildOnly: true, args: [ { @@ -21,9 +21,8 @@ module.exports = class WarnCommand extends Command { prompt: 'What do you want to set the reason as?', type: 'string', validate: reason => { - if(reason.length < 140) - return true; - return `Please keep your reason under 140 characters, you have ${reason.length}.`; + if(reason.length < 140) return true; + return 'Invalid Reason. Reason must be under 140 characters.'; } } ] @@ -35,7 +34,7 @@ module.exports = class WarnCommand extends Command { } async run(msg, args) { - const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog', 'mod_logs')); + const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog')); if(!modlogs) return msg.say('This Command requires a channel set with the `modchannel` command.'); if(!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) @@ -54,7 +53,7 @@ module.exports = class WarnCommand extends Command { `); return modlogs.send({ embed }); } catch(err) { - return msg.say('An Unknown Error Occurred.'); + return msg.say(`An Error Occurred: ${err}`); } } }; diff --git a/commands/random/currency.js b/commands/random/currency.js index 4f5131b8..f03626af 100644 --- a/commands/random/currency.js +++ b/commands/random/currency.js @@ -16,9 +16,8 @@ module.exports = class CurrencyCommand extends Command { prompt: 'What currency code do you want to use as the base?', type: 'string', validate: base => { - if(codes.includes(base.toUpperCase())) - return true; - return `${base} is not a valid currency code. Use \`help currency\` to view a list of codes.`; + if(codes.includes(base.toUpperCase())) return true; + return 'Invalid Currency Code. Use `help currency` to view a list of currency codes.'; }, parse: base => base.toUpperCase() }, @@ -27,9 +26,8 @@ module.exports = class CurrencyCommand extends Command { prompt: 'What currency code do you want to convert to?', type: 'string', validate: to => { - if(codes.includes(to.toUpperCase())) - return true; - return `${to} is not a valid currency code. Use \`help currency\` to view a list of codes.`; + if(codes.includes(to.toUpperCase())) return true; + return 'Invalid Currency Code. Use `help currency` to view a list of currency codes.'; }, parse: to => to.toUpperCase() }, @@ -52,7 +50,7 @@ module.exports = class CurrencyCommand extends Command { const converted = rate * amount; return msg.say(`${amount} ${base} is ${converted} ${to}.`); } catch(err) { - return msg.say('An Unknown Error Occurred.'); + return msg.say(`An Error Occurred: ${err}`); } } }; diff --git a/commands/random/easteregg.js b/commands/random/easteregg.js index af554829..7720dc49 100644 --- a/commands/random/easteregg.js +++ b/commands/random/easteregg.js @@ -17,8 +17,7 @@ module.exports = class EasterEggCommand extends Command { prompt: 'What easter egg do you want to view?', type: 'string', validate: tag => { - if(eastereggs[tag.toLowerCase()]) - return true; + if(eastereggs[tag.toLowerCase()]) return true; return 'Nope, that\'s not a valid easter egg. Try again!'; }, parse: tag => tag.toLowerCase() diff --git a/commands/random/strawpoll.js b/commands/random/strawpoll.js index 7993ebf1..8e8d0ed6 100644 --- a/commands/random/strawpoll.js +++ b/commands/random/strawpoll.js @@ -15,9 +15,8 @@ module.exports = class StrawpollCommand extends Command { prompt: 'What would you like the title of the Strawpoll to be?', type: 'string', validate: title => { - if(title.length < 200) - return true; - return `Please keep your title under 200 characters, you have ${title.length}.`; + if(title.length < 200) return true; + return 'Invalid Title. Title must be under 200 characters.'; } }, { @@ -26,9 +25,8 @@ module.exports = class StrawpollCommand extends Command { type: 'string', infinite: true, validate: choice => { - if(choice.length < 160) - return true; - return `Please keep your options under 160 characters each, you have ${choice.length}.`; + if(choice.length < 160) return true; + return 'Invalid Choice. Choices must be under 140 characters each.'; } } ] @@ -50,7 +48,7 @@ module.exports = class StrawpollCommand extends Command { http://strawpoll.me/${body.id} `); } catch(err) { - return msg.say('An Unknown Error Occurred.'); + return msg.say(`An Error Occurred: ${err}`); } } }; diff --git a/commands/random/today.js b/commands/random/today.js index 0aa565ea..fb53924c 100644 --- a/commands/random/today.js +++ b/commands/random/today.js @@ -31,7 +31,7 @@ module.exports = class TodayCommand extends Command { .setDescription(`${events[random].year}: ${events[random].text}`); return msg.embed(embed); } catch(err) { - return msg.say('An Unknown Error Occurred.'); + return msg.say(`An Error Occurred: ${err}`); } } }; diff --git a/commands/random/wouldyourather.js b/commands/random/wouldyourather.js index 4338939d..5acf2565 100644 --- a/commands/random/wouldyourather.js +++ b/commands/random/wouldyourather.js @@ -29,7 +29,7 @@ module.exports = class WouldYouRatherCommand extends Command { .setDescription(`${body.choicea} OR ${body.choiceb}?`); return msg.embed(embed); } catch(err) { - return msg.say('An Unknown Error Occurred.'); + return msg.say(`An Error Occurred: ${err}`); } } }; diff --git a/commands/randomimg/cat.js b/commands/randomimg/cat.js index c3c0302f..66917a94 100644 --- a/commands/randomimg/cat.js +++ b/commands/randomimg/cat.js @@ -24,7 +24,7 @@ module.exports = class CatCommand extends Command { return msg.channel.send({ files: [body.file] }) .catch(err => msg.say(`An Error Occurred: ${err}`)); } catch(err) { - return msg.say('An Unknown Error Occurred.'); + return msg.say(`An Error Occurred: ${err}`); } } }; diff --git a/commands/randomimg/dog.js b/commands/randomimg/dog.js index 21905ef3..0a012a5a 100644 --- a/commands/randomimg/dog.js +++ b/commands/randomimg/dog.js @@ -21,7 +21,7 @@ module.exports = class DogCommand extends Command { return msg.channel.send({ files: [body.url] }) .catch(err => msg.say(`An Error Occurred: ${err}`)); } catch(err) { - return msg.say('An Unknown Error Occurred.'); + return msg.say(`An Error Occurred: ${err}`); } } }; diff --git a/commands/response/name.js b/commands/response/name.js index e2d3eeb0..849913bd 100644 --- a/commands/response/name.js +++ b/commands/response/name.js @@ -14,8 +14,7 @@ module.exports = class RandomNameCommand extends Command { prompt: 'Which gender do you want to generate a name for?', type: 'string', validate: gender => { - if(['male', 'female'].includes(gender.toLowerCase())) - return true; + if(['male', 'female'].includes(gender.toLowerCase())) return true; return 'Please enter either `male` or `female`.'; }, parse: gender => gender.toLowerCase() diff --git a/commands/search/botinfo.js b/commands/search/botinfo.js index 7b6fef0f..392068ba 100644 --- a/commands/search/botinfo.js +++ b/commands/search/botinfo.js @@ -42,7 +42,7 @@ module.exports = class BotSearchCommand extends Command { body.prefix, true); return msg.embed(embed); } catch(err) { - return msg.say('An Error Occurred. The bot may not have been found.'); + return msg.say(`An Error Occurred: ${err}`); } } }; diff --git a/commands/search/define.js b/commands/search/define.js index 3d7dee59..a26b26be 100644 --- a/commands/search/define.js +++ b/commands/search/define.js @@ -28,13 +28,14 @@ module.exports = class DefineCommand extends Command { try { const { body } = await request .get(`http://api.wordnik.com:80/v4/word.json/${query}/definitions?limit=1&includeRelated=false&useCanonical=false&api_key=${process.env.WORDNIK_KEY}`); + if(body.length === 0) throw new Error('No Results.'); const embed = new RichEmbed() .setColor(0x9797FF) .setTitle(body[0].word) .setDescription(body[0].text); return msg.embed(embed); } catch(err) { - return msg.say('An Error Occurred. The word may not have been found.'); + return msg.say(`An Error Occurred: ${err}`); } } }; diff --git a/commands/search/discrim.js b/commands/search/discrim.js index c670e496..910f063d 100644 --- a/commands/search/discrim.js +++ b/commands/search/discrim.js @@ -18,8 +18,7 @@ module.exports = class DiscrimCommand extends Command { prompt: 'Which discriminator would you like to search for?', type: 'string', validate: discrim => { - if(/[0-9]+$/g.test(discrim) && discrim.length === 4) - return true; + if(/[0-9]+$/g.test(discrim) && discrim.length === 4) return true; return `${discrim} is not a valid discriminator.`; } } diff --git a/commands/search/forecast.js b/commands/search/forecast.js index 0da7fe58..87f59c90 100644 --- a/commands/search/forecast.js +++ b/commands/search/forecast.js @@ -27,6 +27,7 @@ module.exports = class ForecastCommand extends Command { try { const { body } = await request .get(`https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where u=\'f\' AND woeid in (select woeid from geo.places(1) where text="${query}")&format=json`); + if(body.query.count === 0) throw new Error('Location Not Found.'); const forecasts = body.query.results.channel.item.forecast; const embed = new RichEmbed() .setColor(0x0000FF) @@ -49,7 +50,7 @@ module.exports = class ForecastCommand extends Command { `**High:** ${forecasts[6].high}°F, **Low:** ${forecasts[6].low}°F, **Condition:** ${forecasts[6].text}`); return msg.embed(embed); } catch(err) { - return msg.say('An Error Occurred. The location may not have been found.'); + return msg.say(`An Error Occurred: ${err}`); } } }; diff --git a/commands/search/google.js b/commands/search/google.js index b15b2f1d..6a653960 100644 --- a/commands/search/google.js +++ b/commands/search/google.js @@ -29,11 +29,11 @@ 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'); + if(!href) throw new Error('No Results.'); href = querystring.parse(href.replace('/url?', '')); return message.edit(href.q); } catch(err) { - return message.edit('No Results Found.'); + return message.edit('An Error Occurred: No Results.'); } } }; diff --git a/commands/search/imdb.js b/commands/search/imdb.js index 84b0b8ae..ca80fe48 100644 --- a/commands/search/imdb.js +++ b/commands/search/imdb.js @@ -28,6 +28,7 @@ module.exports = class IMDBCommand extends Command { try { const { body } = await request .get(`http://www.omdbapi.com/?t=${query}&plot=full`); + if(body.Error) throw new Error('No Results.'); const embed = new RichEmbed() .setColor(0xDBA628) .setAuthor('IMDB', 'https://i.imgur.com/sXwwIQs.png') @@ -50,7 +51,7 @@ module.exports = class IMDBCommand extends Command { body.Actors); return msg.embed(embed); } catch(err) { - return msg.say('An Error Occurred. The film may not have been found.'); + return msg.say(`An Error Occurred: ${err}`); } } }; diff --git a/commands/search/map.js b/commands/search/map.js index 1df37451..46c96221 100644 --- a/commands/search/map.js +++ b/commands/search/map.js @@ -41,7 +41,7 @@ module.exports = class MapCommand extends Command { return msg.channel.send({ files: [{ attachment: body, name: 'map.png' }] }) .catch(err => msg.say(`An Error Occurred: ${err}`)); } catch(err) { - return msg.say('An Error Occurred. The location may not have been found.'); + return msg.say(`An Error Occurred: ${err}`); } } }; diff --git a/commands/search/neopet.js b/commands/search/neopet.js index 85f3a38c..4e863915 100644 --- a/commands/search/neopet.js +++ b/commands/search/neopet.js @@ -27,11 +27,10 @@ module.exports = class NeopetCommand extends Command { .get(`http://www.sunnyneo.com/petimagefinder.php?name=${query}&size=5&mood=1`); const $ = cheerio.load(text); const link = $('textarea').first().text(); - if(!link.includes('cp')) - return msg.say('This is not a valid pet name.'); + if(!link.includes('cp')) throw new Error('Invalid Pet Name.'); return msg.say(link); } catch(err) { - return msg.say('An Unknown Error Occurred.'); + return msg.say(`An Error Occurred: ${err}`); } } }; diff --git a/commands/search/osu.js b/commands/search/osu.js index 7e307544..3004408a 100644 --- a/commands/search/osu.js +++ b/commands/search/osu.js @@ -28,6 +28,7 @@ module.exports = class OsuCommand extends Command { try { const { body } = await request .get(`https://osu.ppy.sh/api/get_user?k=${process.env.OSU_KEY}&u=${query}&type=string`); + if(body.length === 0) throw new Error('No Results.'); const embed = new RichEmbed() .setColor(0xFF66AA) .setAuthor('osu!', 'https://i.imgur.com/EmnUp00.png') @@ -58,7 +59,7 @@ module.exports = class OsuCommand extends Command { body[0].count_rank_a, true); return msg.embed(embed); } catch(err) { - return msg.say('An Error Occurred. The user may not have been found.'); + return msg.say(`An Error Occurred: ${err}`); } } }; diff --git a/commands/search/soundcloud.js b/commands/search/soundcloud.js index c296def7..095a8461 100644 --- a/commands/search/soundcloud.js +++ b/commands/search/soundcloud.js @@ -28,6 +28,7 @@ module.exports = class SoundCloudCommand extends Command { try { const { body } = await request .get(`https://api.soundcloud.com/tracks?q=${query}&client_id=${process.env.SOUNDCLOUD_KEY}`); + if(body.length === 0) throw new Error('No Results.'); const embed = new RichEmbed() .setColor(0xF15A22) .setAuthor(body[0].title, 'https://i.imgur.com/lFIz7RU.png') @@ -45,7 +46,7 @@ module.exports = class SoundCloudCommand extends Command { body[0].favoritings_count, true); return msg.embed(embed); } catch(err) { - return msg.say('An Error Occurred. The song may not have been found.'); + return msg.say(`An Error Occurred: ${err}`); } } }; diff --git a/commands/search/urban.js b/commands/search/urban.js index 16950d81..cb5d8292 100644 --- a/commands/search/urban.js +++ b/commands/search/urban.js @@ -28,6 +28,7 @@ module.exports = class UrbanCommand extends Command { try { const { body } = await request .get(`http://api.urbandictionary.com/v0/define?term=${query}`); + if(body.list.length === 0) throw new Error('No Results.'); const embed = new RichEmbed() .setColor(0x32a8f0) .setAuthor('Urban Dictionary', 'https://i.imgur.com/fzFuuL7.png') @@ -38,7 +39,7 @@ module.exports = class UrbanCommand extends Command { body.list[0].example.substr(0, 2000) || 'None'); return msg.embed(embed); } catch(err) { - return msg.say('An Error Occurred. The word may not have been found.'); + return msg.say(`An Error Occurred: ${err}`); } } }; diff --git a/commands/search/wattpad.js b/commands/search/wattpad.js index b91d14ef..abce010b 100644 --- a/commands/search/wattpad.js +++ b/commands/search/wattpad.js @@ -29,6 +29,7 @@ module.exports = class WattpadCommand extends Command { const { body } = await request .get(`https://api.wattpad.com:443/v4/stories?query=${query}&limit=1`) .set({ 'Authorization': `Basic ${process.env.WATTPAD_KEY}` }); + if(body.stories.length === 0) throw new Error('No Results.'); const embed = new RichEmbed() .setColor(0xF89C34) .setAuthor('Wattpad', 'https://i.imgur.com/Rw9vRQB.png') @@ -49,7 +50,7 @@ module.exports = class WattpadCommand extends Command { body.stories[0].commentCount, true); return msg.embed(embed); } catch(err) { - return msg.say('An Error Occurred. The book may not have been found.'); + return msg.say(`An Error Occurred: ${err}`); } } }; diff --git a/commands/search/weather.js b/commands/search/weather.js index 22683b47..bf5cd039 100644 --- a/commands/search/weather.js +++ b/commands/search/weather.js @@ -27,6 +27,7 @@ module.exports = class WeatherCommand extends Command { try { const { body } = await request .get(`https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where u=\'f\' AND woeid in (select woeid from geo.places(1) where text="${query}")&format=json`); + if(body.query.count === 0) throw new Error('Location Not Found.'); const embed = new RichEmbed() .setColor(0x0000FF) .setAuthor(body.query.results.channel.title, 'https://i.imgur.com/2MT0ViC.png') @@ -58,7 +59,7 @@ module.exports = class WeatherCommand extends Command { body.query.results.channel.wind.speed, true); return msg.embed(embed); } catch(err) { - return msg.say('An Error Occurred. The location may not have been found.'); + return msg.say(`An Error Occurred: ${err}`); } } }; diff --git a/commands/search/wikipedia.js b/commands/search/wikipedia.js index 0e4c04db..6f5e92ab 100644 --- a/commands/search/wikipedia.js +++ b/commands/search/wikipedia.js @@ -28,6 +28,7 @@ module.exports = class WikipediaCommand extends Command { try { const { body } = await request .get(`https://en.wikipedia.org/w/api.php?action=query&prop=extracts&format=json&titles=${query}&exintro=&explaintext=&redirects=&formatversion=2`); + if(body.query.pages[0].missing) throw new Error('No Results.'); const embed = new RichEmbed() .setColor(0xE7E7E7) .setTitle(body.query.pages[0].title) @@ -36,7 +37,7 @@ module.exports = class WikipediaCommand extends Command { .setDescription(body.query.pages[0].extract.substr(0, 2000).replace(/[\n]/g, '\n\n')); return msg.embed(embed); } catch(err) { - return msg.say('An Error Occurred. The page may not have been found.'); + return msg.say(`An Error Occurred: ${err}`); } } }; diff --git a/commands/search/youtube.js b/commands/search/youtube.js index 47e6e7a0..632fc71c 100644 --- a/commands/search/youtube.js +++ b/commands/search/youtube.js @@ -28,6 +28,7 @@ module.exports = class YouTubeCommand extends Command { try { const { body } = await request .get(`https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&maxResults=1&q=${query}&key=${process.env.GOOGLE_KEY}`); + if(body.items.length === 0) throw new Error('No Results.'); const embed = new RichEmbed() .setColor(0xDD2825) .setTitle(body.items[0].snippet.title) @@ -37,7 +38,7 @@ module.exports = class YouTubeCommand extends Command { .setThumbnail(body.items[0].snippet.thumbnails.default.url); return msg.embed(embed); } catch(err) { - return msg.say('An Error Occurred. The video may not have been found.'); + return msg.say(`An Error Occurred: ${err}`); } } }; diff --git a/commands/search/yugioh.js b/commands/search/yugioh.js index 420d73f3..39e09e35 100644 --- a/commands/search/yugioh.js +++ b/commands/search/yugioh.js @@ -28,6 +28,7 @@ module.exports = class YuGiOhCommand extends Command { try { const { body } = await request .get(`http://yugiohprices.com/api/card_data/${query}`); + if(body.status === 'fail') throw new Error('No Results.'); if(body.data.card_type === 'monster') { const embed = new RichEmbed() .setColor(0xBE5F1F) @@ -35,7 +36,7 @@ module.exports = class YuGiOhCommand extends Command { .setDescription(body.data.text) .setAuthor('Yu-Gi-Oh!', 'https://i.imgur.com/7gPm9Rr.png') .addField('**Card Type:**', - 'Monster', true) + 'monster', true) .addField('**Type:**', body.data.type, true) .addField('**Attribute:**', @@ -57,7 +58,7 @@ module.exports = class YuGiOhCommand extends Command { body.data.card_type, true); return msg.embed(embed); } catch(err) { - return msg.say('An Error Occurred. The card may not have been found.'); + return msg.say(`An Error Occurred: ${err}`); } } }; diff --git a/commands/textedit/binary.js b/commands/textedit/binary.js index 9f6d9651..a15b363b 100644 --- a/commands/textedit/binary.js +++ b/commands/textedit/binary.js @@ -20,9 +20,8 @@ module.exports = class BinaryCommand extends Command { prompt: 'What text would you like to convert to binary?', type: 'string', validate: text => { - if(binary(text).length < 2000) - return true; - return 'Your message content is too long.'; + if(binary(text).length < 2000) return true; + return 'Your text is too long.'; }, parse: text => binary(text) } diff --git a/commands/textedit/cowsay.js b/commands/textedit/cowsay.js index 2bded6b9..4aa8d752 100644 --- a/commands/textedit/cowsay.js +++ b/commands/textedit/cowsay.js @@ -14,9 +14,8 @@ module.exports = class CowsayCommand extends Command { prompt: 'What text would you like the cow to say?', type: 'string', validate: text => { - if(text.length < 1500) - return true; - return `Please keep your content under 1500 characters, you have ${text.length}.`; + if(text.length < 1500) return true; + return 'Invalid Text. Text must be under 1500 characters.'; } } ] diff --git a/commands/textedit/morse.js b/commands/textedit/morse.js index 646d6ea9..b0e2b23f 100644 --- a/commands/textedit/morse.js +++ b/commands/textedit/morse.js @@ -15,9 +15,8 @@ module.exports = class MorseCommand extends Command { prompt: 'What text would you like to convert to morse?', type: 'string', validate: text => { - if(letterTrans(text, dictionary, ' ').length < 1999) - return true; - return 'Your message content is too long.'; + if(letterTrans(text, dictionary, ' ').length < 1999) return true; + return 'Your text is too long.'; }, parse: text => letterTrans(text.toLowerCase(), dictionary, ' ') } diff --git a/commands/textedit/pirate.js b/commands/textedit/pirate.js index 67af5c91..f55e4412 100644 --- a/commands/textedit/pirate.js +++ b/commands/textedit/pirate.js @@ -15,9 +15,8 @@ module.exports = class PirateCommand extends Command { prompt: 'What text would you like to convert to pirate?', type: 'string', validate: text => { - if(wordTrans(text, dictionary).length < 1999) - return true; - return 'Your message content is too long.'; + if(wordTrans(text, dictionary).length < 1999) return true; + return 'Your text is too long.'; }, parse: text => wordTrans(text, dictionary) } diff --git a/commands/textedit/temmie.js b/commands/textedit/temmie.js index ba1e43a9..c5c51ea7 100644 --- a/commands/textedit/temmie.js +++ b/commands/textedit/temmie.js @@ -15,9 +15,8 @@ module.exports = class TemmieCommand extends Command { prompt: 'What text would you like to convert to Temmie speak?', type: 'string', validate: text => { - if(wordTrans(text, dictionary).length < 1999) - return true; - return 'Your message content is too long.'; + if(wordTrans(text, dictionary).length < 1999) return true; + return 'Your text is too long.'; }, parse: text => wordTrans(text, dictionary) } diff --git a/commands/textedit/webhook.js b/commands/textedit/webhook.js index 3809d3b6..b794e6e0 100644 --- a/commands/textedit/webhook.js +++ b/commands/textedit/webhook.js @@ -38,7 +38,7 @@ module.exports = class WebhookCommand extends Command { .send({ content }); return null; } catch(err) { - return msg.say('An Unknown Error Occurred.'); + return msg.say(`An Error Occurred: ${err}`); } } }; diff --git a/commands/textedit/zalgo.js b/commands/textedit/zalgo.js index aed03baf..631d8347 100644 --- a/commands/textedit/zalgo.js +++ b/commands/textedit/zalgo.js @@ -14,9 +14,8 @@ module.exports = class ZalgoCommand extends Command { prompt: 'What text would you like to convert to zalgo?', type: 'string', validate: text => { - if(text.length < 500) - return true; - return `Please keep your text under 500 characters, you have ${text.length}.`; + if(text.length < 500) return true; + return 'Invalid Text. Text must be under 500 characters.'; }, parse: text => zalgo(text) } diff --git a/commands/util/clearsetting.js b/commands/util/clearsetting.js index 133f0cfc..236140ef 100644 --- a/commands/util/clearsetting.js +++ b/commands/util/clearsetting.js @@ -14,8 +14,7 @@ module.exports = class ClearSettingCommand extends Command { prompt: 'What setting do you want to clear? `modLog`, `memberLog`, `staffRole`, or `singleRole`?', type: 'string', validate: setting => { - if(['modLog', 'memberLog', 'staffRole', 'singleRole'].includes(setting)) - return true; + if(['modLog', 'memberLog', 'staffRole', 'singleRole'].includes(setting)) return true; return 'Please enter either `modLog`, `memberLog`, `staffRole`, or `singleRole`.'; } } diff --git a/package.json b/package.json index 9d7d70bd..5f657462 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "18.2.1", + "version": "18.2.2", "description": "A Discord Bot", "main": "shardingmanager.js", "scripts": {