From 49d092d7c1592363c1f2933070d0c76dac84a9c3 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Tue, 25 Apr 2017 17:37:01 +0000 Subject: [PATCH] A variety of fixes and a change in the way errors are handled. --- commands/avataredit/3000years.js | 4 ++-- commands/avataredit/beautiful.js | 4 ++-- commands/avataredit/bobross.js | 4 ++-- commands/avataredit/rip.js | 4 ++-- commands/avataredit/steamcard.js | 4 ++-- commands/games/mathgame.js | 4 ++-- commands/games/quiz.js | 2 +- commands/games/rockpaperscissors.js | 2 +- commands/games/typinggame.js | 4 ++-- commands/guildinfo/emoji.js | 2 +- commands/guildinfo/guildinfo.js | 2 +- commands/imageedit/meme.js | 4 ++-- commands/moderation/ban.js | 15 ++++++++++----- commands/moderation/kick.js | 19 ++++++++++++------- commands/moderation/lockdown.js | 14 +++++++------- commands/moderation/prune.js | 6 +++--- commands/moderation/unban.js | 10 +++++----- commands/moderation/warn.js | 8 +++----- commands/random/math.js | 4 ++-- commands/random/nitro.js | 2 +- commands/random/spam.js | 2 +- commands/random/strawpoll.js | 6 +++--- commands/random/today.js | 4 ++-- commands/random/wouldyourather.js | 4 ++-- commands/randomimg/cat.js | 2 +- commands/randomimg/potato.js | 2 +- commands/randomimg/pun.js | 2 +- commands/randomimg/xiaopai.js | 2 +- commands/search/botinfo.js | 4 ++-- commands/search/define.js | 4 ++-- commands/search/discrim.js | 2 +- commands/search/forecast.js | 4 ++-- commands/search/google.js | 2 +- commands/search/imdb.js | 4 ++-- commands/search/map.js | 4 ++-- commands/search/neopet.js | 7 ++----- commands/search/osu.js | 4 ++-- commands/search/soundcloud.js | 4 ++-- commands/search/urban.js | 4 ++-- commands/search/wattpad.js | 4 ++-- commands/search/weather.js | 4 ++-- commands/search/wikipedia.js | 4 ++-- commands/search/youtube.js | 4 ++-- commands/search/yugioh.js | 4 ++-- commands/textedit/embed.js | 2 +- commands/textedit/say.js | 4 ++++ commands/textedit/webhook.js | 4 ++-- commands/userinfo/userinfo.js | 2 +- commands/util/info.js | 2 +- commands/util/shardinfo.js | 4 ++-- package.json | 2 +- 51 files changed, 117 insertions(+), 108 deletions(-) diff --git a/commands/avataredit/3000years.js b/commands/avataredit/3000years.js index d7672757..0db3f99a 100644 --- a/commands/avataredit/3000years.js +++ b/commands/avataredit/3000years.js @@ -22,7 +22,7 @@ module.exports = class YearsCommand extends Command { async run(message, args) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) - return message.say(':x: Error! I don\'t have the Attach Files Permission!'); + return message.say('This Command requires the `Attach Files` Permission.'); const { user } = args; const userAvatar = user.displayAvatarURL.replace('.jpg', '.png').replace('.gif', '.png'); let images = []; @@ -32,7 +32,7 @@ module.exports = class YearsCommand extends Command { avatar.resize(200, 200); years.blit(avatar, 461, 127); years.getBuffer(Jimp.MIME_PNG, (err, buff) => { - if (err) return message.say(':x: Error! Something went wrong!'); + if (err) return message.say('An Unknown Error Occurred.'); return message.channel.send({files: [{attachment: buff}]}); }); } diff --git a/commands/avataredit/beautiful.js b/commands/avataredit/beautiful.js index d2d1b331..07852324 100644 --- a/commands/avataredit/beautiful.js +++ b/commands/avataredit/beautiful.js @@ -22,7 +22,7 @@ module.exports = class BeautifulCommand extends Command { async run(message, args) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) - return message.say(':x: Error! I don\'t have the Attach Files Permission!'); + return message.say('This Command requires the `Attach Files` Permission.'); const { user } = args; const userAvatar = user.displayAvatarURL.replace('.jpg', '.png').replace('.gif', '.png'); let images = []; @@ -34,7 +34,7 @@ module.exports = class BeautifulCommand extends Command { avatar.resize(190, 190); beautiful.blit(avatar, 451, 434); beautiful.getBuffer(Jimp.MIME_PNG, (err, buff) => { - if (err) return message.say(':x: Error! Something went wrong!'); + if (err) return message.say('An Unknown Error Occurred.'); return message.channel.send({files: [{attachment: buff}]}); }); } diff --git a/commands/avataredit/bobross.js b/commands/avataredit/bobross.js index 82f93266..c9b142be 100644 --- a/commands/avataredit/bobross.js +++ b/commands/avataredit/bobross.js @@ -22,7 +22,7 @@ module.exports = class BobRossCommand extends Command { async run(message, args) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) - return message.say(':x: Error! I don\'t have the Attach Files Permission!'); + return message.say('This Command requires the `Attach Files` Permission.'); const { user } = args; const userAvatar = user.displayAvatarURL.replace('.jpg', '.png').replace('.gif', '.png'); const blank = new Jimp(600, 775, 0xFFFFFF); @@ -35,7 +35,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 message.say(':x: Error! Something went wrong!'); + if (err) return message.say('An Unknown Error Occurred.'); return message.channel.send({files: [{attachment: buff}]}); }); } diff --git a/commands/avataredit/rip.js b/commands/avataredit/rip.js index 842205c5..bde914d2 100644 --- a/commands/avataredit/rip.js +++ b/commands/avataredit/rip.js @@ -23,7 +23,7 @@ module.exports = class RIPCommand extends Command { async run(message, args) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) - return message.say(':x: Error! I don\'t have the Attach Files Permission!'); + return message.say('This Command requires the `Attach Files` Permission.'); const { user } = args; const userAvatar = user.displayAvatarURL.replace('.jpg', '.png').replace('.gif', '.png'); let images = []; @@ -33,7 +33,7 @@ module.exports = class RIPCommand extends Command { avatar.resize(200, 200); gravestone.blit(avatar, 158, 51); gravestone.getBuffer(Jimp.MIME_PNG, (err, buff) => { - if (err) return message.say(':x: Error! Something went wrong!'); + if (err) return message.say('An Unknown Error Occurred.'); return message.channel.send({files: [{attachment: buff}]}); }); } diff --git a/commands/avataredit/steamcard.js b/commands/avataredit/steamcard.js index 8aaec413..c4da6983 100644 --- a/commands/avataredit/steamcard.js +++ b/commands/avataredit/steamcard.js @@ -22,7 +22,7 @@ module.exports = class SteamCardCommand extends Command { async run(message, args) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) - return message.say(':x: Error! I don\'t have the Attach Files Permission!'); + return message.say('This Command requires the `Attach Files` Permission.'); const { user } = args; const username = message.guild ? message.guild.member(user).displayName : user.username; const userAvatar = user.displayAvatarURL.replace('.jpg', '.png').replace('.gif', '.png'); @@ -37,7 +37,7 @@ module.exports = class SteamCardCommand extends Command { blank.composite(steamcard, 0, 0); blank.print(font, 38, 20, username); blank.getBuffer(Jimp.MIME_PNG, (err, buff) => { - if (err) return message.say(':x: Error! Something went wrong!'); + if (err) return message.say('An Unknown Error Occurred.'); return message.channel.send({files: [{attachment: buff}]}); }); } diff --git a/commands/games/mathgame.js b/commands/games/mathgame.js index af45f644..5b9e3fc9 100644 --- a/commands/games/mathgame.js +++ b/commands/games/mathgame.js @@ -12,7 +12,7 @@ module.exports = class MathGameCommand extends Command { description: 'See how fast you can answer a math problem in a given time limit.', 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 math game be? `Easy`, `Medium`, `Hard`, `Extreme`, or `Impossible`?', type: 'string', validate: difficulty => { if (['easy', 'medium', 'hard', 'extreme', 'impossible'].includes(difficulty.toLowerCase())) @@ -27,7 +27,7 @@ module.exports = class MathGameCommand extends Command { async run(message, args) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) - return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + return message.say('This Command requires the `Embed Links` Permission.'); const { difficulty } = args; const operation = operations[Math.floor(Math.random() * operations.length)]; let value; diff --git a/commands/games/quiz.js b/commands/games/quiz.js index 2f992467..84d4170c 100644 --- a/commands/games/quiz.js +++ b/commands/games/quiz.js @@ -18,7 +18,7 @@ module.exports = class QuizCommand extends Command { async run(message) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) - return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + return message.say('This Command requires the `Embed Links` Permission.'); try { const { body } = await request .get('http://jservice.io/api/random?count=1'); diff --git a/commands/games/rockpaperscissors.js b/commands/games/rockpaperscissors.js index 49327d9f..457f1b1f 100644 --- a/commands/games/rockpaperscissors.js +++ b/commands/games/rockpaperscissors.js @@ -13,7 +13,7 @@ module.exports = class RockPaperScissorsCommand extends Command { description: 'Play Rock-Paper-Scissors.', args: [{ key: 'choice', - prompt: 'Rock, Paper, or Scissors?', + prompt: '`Rock`, `Paper`, or `Scissors`?', type: 'string', validate: rps => { if (['rock', 'paper', 'scissors'].includes(rps.toLowerCase())) diff --git a/commands/games/typinggame.js b/commands/games/typinggame.js index c48d3d4e..2bd70814 100644 --- a/commands/games/typinggame.js +++ b/commands/games/typinggame.js @@ -11,7 +11,7 @@ module.exports = class TypingGameCommand extends Command { description: 'See how fast you can type a sentence in a given time limit.', 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 typing game be? `Easy`, `Medium`, `Hard`, `Extreme`, or `Impossible`?', type: 'string', validate: difficulty => { if (['easy', 'medium', 'hard', 'extreme', 'impossible'].includes(difficulty.toLowerCase())) @@ -26,7 +26,7 @@ module.exports = class TypingGameCommand extends Command { async run(message, args) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) - return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + return message.say('This Command requires the `Embed Links` Permission.'); const { difficulty } = args; const sentence = sentences[Math.floor(Math.random() * sentences.length)]; let time; diff --git a/commands/guildinfo/emoji.js b/commands/guildinfo/emoji.js index ae24b5ef..56400a8e 100644 --- a/commands/guildinfo/emoji.js +++ b/commands/guildinfo/emoji.js @@ -13,6 +13,6 @@ 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?')); + .catch(() => message.say('There was an error sending the emoji. Perhaps you have no custom emoji?')); } }; diff --git a/commands/guildinfo/guildinfo.js b/commands/guildinfo/guildinfo.js index 6b39921e..eaf065d6 100644 --- a/commands/guildinfo/guildinfo.js +++ b/commands/guildinfo/guildinfo.js @@ -21,7 +21,7 @@ module.exports = class GuildInfoCommand extends Command { run(message) { if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) - return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + return message.say('This Command requires the `Embed Links` Permission.'); const embed = new RichEmbed() .setColor(0x00AE86) .setThumbnail(message.guild.iconURL) diff --git a/commands/imageedit/meme.js b/commands/imageedit/meme.js index 44baa043..8142eacd 100644 --- a/commands/imageedit/meme.js +++ b/commands/imageedit/meme.js @@ -46,9 +46,9 @@ module.exports = class MemeCommand extends Command { run(message, args) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) - return message.say(':x: Error! I don\'t have the Attach Files Permission!'); + return message.say('This Command requires the `Attach Files` Permission.'); const { type, toprow, bottomrow } = args; return message.channel.send({files: [`https://memegen.link/${type}/${toprow}/${bottomrow}.jpg`]}) - .catch(() => message.say(':x: Error! Something went wrong!')); + .catch(() => message.say('An Unknown Error Occurred.')); } }; diff --git a/commands/moderation/ban.js b/commands/moderation/ban.js index 8478037c..ef4fd58a 100644 --- a/commands/moderation/ban.js +++ b/commands/moderation/ban.js @@ -36,16 +36,21 @@ module.exports = class BanCommand extends Command { async run(message, args) { if (!message.channel.permissionsFor(this.client.user).hasPermission('BAN_MEMBERS')) - return message.say(':x: Error! I don\'t have the Ban Members Permission!'); + return message.say('This Command requires the `Ban Members` Permission.'); const modlogs = message.guild.channels.find('name', 'mod_logs'); if (!modlogs) - return message.say(':x: Error! Could not find the mod_logs channel! Please create it!'); + return message.say('This Command requires a channel named `mod_logs`.'); if (!modlogs.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) - return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + return message.say('This Command requires the `Embed Links` Permission.'); const { member, reason } = args; if (!member.bannable) - return message.say(':x: Error! This member cannot be banned! Perhaps they have a higher role than me?'); + return message.say('This member is not bannable. Perhaps they have a higher role than me?'); try { + try { + await member.send(`You were banned from ${message.guild.name}!\nReason: ${reason}.`); + } catch (err) { + await message.say('Failed to send DM to user.'); + } await member.ban(7); await message.say(':ok_hand:'); const embed = new RichEmbed() @@ -55,7 +60,7 @@ module.exports = class BanCommand extends Command { .setDescription(`**Member:** ${member.user.tag} (${member.id})\n**Action:** Ban\n**Reason:** ${reason}`); return modlogs.send({embed}); } catch (err) { - return message.say(':x: Error! Something went wrong!'); + return message.say('An Unknown Error Occurred.'); } } }; diff --git a/commands/moderation/kick.js b/commands/moderation/kick.js index c8472ed2..ff6ad3f0 100644 --- a/commands/moderation/kick.js +++ b/commands/moderation/kick.js @@ -32,17 +32,22 @@ module.exports = class KickCommand extends Command { } async run(message, args) { - if (!message.channel.permissionsFor(this.client.user).hasPermission('BAN_MEMBERS')) - return message.say(':x: Error! I don\'t have the Ban Members Permission!'); + if (!message.channel.permissionsFor(this.client.user).hasPermission('KICK_MEMBERS')) + return message.say('This Command requires the `Kick Members` Permission.'); const modlogs = message.guild.channels.find('name', 'mod_logs'); if (!modlogs) - return message.say(':x: Error! Could not find the mod_logs channel! Please create it!'); + return message.say('This Command requires a channel named `mod_logs`.'); if (!modlogs.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) - return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + return message.say('This Command requires the `Embed Links` Permission.'); const { member, reason } = args; - if (!member.bannable) - return message.say(':x: Error! This member cannot be kicked! Perhaps they have a higher role than me?'); + if (!member.kickable) + return message.say('This member is not kickable. Perhaps they have a higher role than me?'); try { + try { + await member.send(`You were kicked from ${message.guild.name}!\nReason: ${reason}.`); + } catch (err) { + await message.say('Failed to send DM.'); + } await member.kick(); await message.say(':ok_hand:'); const embed = new RichEmbed() @@ -52,7 +57,7 @@ module.exports = class KickCommand extends Command { .setDescription(`**Member:** ${member.user.tag} (${member.id})\n**Action:** Kick\n**Reason:** ${reason}`); return modlogs.send({embed}); } catch (err) { - return message.say(':x: Error! Something went wrong!'); + return message.say('An Unknown Error Occurred.'); } } }; diff --git a/commands/moderation/lockdown.js b/commands/moderation/lockdown.js index 5c3dfed7..1cf9644b 100644 --- a/commands/moderation/lockdown.js +++ b/commands/moderation/lockdown.js @@ -6,11 +6,11 @@ module.exports = class LockdownCommand extends Command { name: 'lockdown', group: 'moderation', memberName: 'lockdown', - description: 'Locks down the current channel or removes a lockdown, which prevents non-roled members from speaking.', + description: 'Locks down the current channel or removes a lockdown, which prevents non-administrator members from speaking.', guildOnly: true, args: [{ key: 'type', - prompt: 'Please enter either start or stop.', + prompt: 'Please enter either `start` or `stop`.', type: 'string', validate: type => { if (['start', 'stop'].includes(type.toLowerCase())) @@ -28,25 +28,25 @@ module.exports = class LockdownCommand extends Command { async run(message, args) { if (!message.channel.permissionsFor(this.client.user).hasPermission('ADMINISTRATOR')) - return message.say(':x: Error! I don\'t have the Administrator Permission!'); + return message.say('This Command requires the `Administrator` Permission.'); const { type } = args; if (type === 'start') { try { await message.channel.overwritePermissions(message.guild.defaultRole, { SEND_MESSAGES: false }); - return message.say('**Lockdown Started, users without Administrator can no longer post messages. Please use `;lockdown stop` to end the lockdown.**'); + return message.say('Lockdown Started, users without Administrator can no longer post messages. Please use `;lockdown stop` to end the lockdown.'); } catch (err) { - return message.say(':x: Error! Something went wrong!'); + return message.say('Something went wrong!'); } } else if (type === 'stop') { try { await message.channel.overwritePermissions(message.guild.defaultRole, { SEND_MESSAGES: true }); - return message.say('**Lockdown Ended, users without Administrator can now post messages.**'); + return message.say('Lockdown Ended, users without Administrator can now post messages.'); } catch (err) { - return message.say(':x: Error! Something went wrong!'); + return message.say('An Unknown Error Occurred.'); } } } diff --git a/commands/moderation/prune.js b/commands/moderation/prune.js index e0d82cc7..0e13c53e 100644 --- a/commands/moderation/prune.js +++ b/commands/moderation/prune.js @@ -31,9 +31,9 @@ module.exports = class PruneCommand extends Command { async run(message, args) { if (!message.channel.permissionsFor(this.client.user).hasPermission('READ_MESSAGE_HISTORY')) - return message.say(':x: Error! I don\'t have the Read Message History Permission!'); + return message.say('This Command requires the `Read Message History` Permission.'); if (!message.channel.permissionsFor(this.client.user).hasPermission('MANAGE_MESSAGES')) - return message.say(':x: Error! I don\'t have the Manage Messages Permission!'); + return message.say('This Command requires the `Manage Messages` Permission.'); let { count } = args; count = count + 1; try { @@ -43,7 +43,7 @@ module.exports = class PruneCommand extends Command { await message.channel.bulkDelete(messages, true); return null; } catch (err) { - return message.say(':x: Error! Something went wrong! Perhaps there are not enough messages in the channel from earlier than two weeks?'); + return message.say('There are no messages younger than two weeks that can be deleted.'); } } }; diff --git a/commands/moderation/unban.js b/commands/moderation/unban.js index 26dd6e31..07ef3923 100644 --- a/commands/moderation/unban.js +++ b/commands/moderation/unban.js @@ -40,16 +40,16 @@ module.exports = class UnbanCommand extends Command { async run(message, args) { if (!message.channel.permissionsFor(this.client.user).hasPermission('BAN_MEMBERS')) - return message.say(':x: Error! I don\'t have the Ban Members Permission!'); + return message.say('This Command requires the `Ban Members` Permission.'); const modlogs = message.guild.channels.find('name', 'mod_logs'); if (!modlogs) - return message.say(':x: Error! Could not find the mod_logs channel! Please create it!'); + return message.say('This Command requires a channel named `mod_logs`.'); if (!modlogs.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) - return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + return message.say('This Command requires the `Embed Links` Permission.'); const { memberID, reason } = args; const bans = await message.guild.fetchBans(); if (!bans.has(memberID)) - return message.say(':x: Error! Could not find this user in the bans.'); + return message.say('This ID is not in the Guild Banlist.'); const unbanUser = await bans.get(memberID); try { await message.guild.unban(unbanUser); @@ -61,7 +61,7 @@ module.exports = class UnbanCommand extends Command { .setDescription(`**Member:** ${unbanUser.tag} (${unbanUser.id})\n**Action:** Unban\n**Reason:** ${reason}`); return modlogs.send({embed}); } catch (err) { - return message.say(':x: Error! Something went wrong!'); + return message.say('An Unknown Error Occurred.'); } } }; diff --git a/commands/moderation/warn.js b/commands/moderation/warn.js index 68597694..c50cb7d1 100644 --- a/commands/moderation/warn.js +++ b/commands/moderation/warn.js @@ -31,13 +31,11 @@ module.exports = class WarnCommand extends Command { } async run(message, args) { - if (!message.channel.permissionsFor(this.client.user).hasPermission('BAN_MEMBERS')) - return message.say(':x: Error! I don\'t have the Ban Members Permission!'); const modlogs = message.guild.channels.find('name', 'mod_logs'); if (!modlogs) - return message.say(':x: Error! Could not find the mod_logs channel! Please create it!'); + return message.say('This Command requires a channel named `mod_logs`.'); if (!modlogs.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) - return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + return message.say('This Command requires the `Embed Links` Permission.'); const { member, reason } = args; try { await message.say(':ok_hand:'); @@ -48,7 +46,7 @@ module.exports = class WarnCommand extends Command { .setDescription(`**Member:** ${member.user.tag} (${member.id})\n**Action:** Warn\n**Reason:** ${reason}`); return modlogs.send({embed}); } catch (err) { - return message.say(':x: Error! Something went wrong!'); + return message.say('An Unknown Error Occurred.'); } } }; diff --git a/commands/random/math.js b/commands/random/math.js index 83b2f7de..5912e25a 100644 --- a/commands/random/math.js +++ b/commands/random/math.js @@ -21,9 +21,9 @@ module.exports = class MathCommand extends Command { try { const solved = math.eval(expression); return message.say(solved) - .catch(() => message.say(':x: Error! Invalid statement!')); + .catch(() => message.say('Invalid statement.')); } catch (err) { - return message.say(':x: Error! Invalid statement!'); + return message.say('Invalid statement.'); } } }; diff --git a/commands/random/nitro.js b/commands/random/nitro.js index 80e2c7fd..0e5d2e06 100644 --- a/commands/random/nitro.js +++ b/commands/random/nitro.js @@ -14,7 +14,7 @@ module.exports = class NitroCommand extends Command { run(message) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) - return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + return message.say('This Command requires the `Embed Links` Permission.'); const embed = new RichEmbed() .setAuthor('Discord Nitro') .setThumbnail('https://pbs.twimg.com/profile_images/814184180649197568/y2eZcVMq.jpg') diff --git a/commands/random/spam.js b/commands/random/spam.js index 5781c4ce..de4f85de 100644 --- a/commands/random/spam.js +++ b/commands/random/spam.js @@ -13,7 +13,7 @@ module.exports = class SpamCommand extends Command { run(message) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) - return message.say(':x: Error! I don\'t have the Attach Files Permission!'); + return message.say('This Command requires the `Attach Files` Permission.'); return message.channel.send({files: ['./images/Spam.jpg']}); } }; diff --git a/commands/random/strawpoll.js b/commands/random/strawpoll.js index c4d9e37f..daf973f0 100644 --- a/commands/random/strawpoll.js +++ b/commands/random/strawpoll.js @@ -34,9 +34,9 @@ module.exports = class StrawpollCommand extends Command { async run(message, args) { const { title, choices } = args; if (choices.length < 2) - return message.say(':x: Error! You provided less than two choices!'); + return message.say('You provided less than two choices.'); if (choices.length > 31) - return message.say(':x: Error! You provided more than thirty choices!'); + return message.say('You provided more than thirty choices.'); try { const { body } = await request .post('https://strawpoll.me/api/v2/polls') @@ -47,7 +47,7 @@ module.exports = class StrawpollCommand extends Command { return message.say(`${body.title}\nhttp://strawpoll.me/${body.id}`); } catch (err) { - return message.say(':x: Error! Something went wrong!'); + return message.say('An Unknown Error Occurred.'); } } }; diff --git a/commands/random/today.js b/commands/random/today.js index d34a5f45..ade22acc 100644 --- a/commands/random/today.js +++ b/commands/random/today.js @@ -15,7 +15,7 @@ module.exports = class TodayCommand extends Command { async run(message) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) - return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + return message.say('This Command requires the `Embed Links` Permission.'); try { const { text } = await request .get('http://history.muffinlabs.com/date') @@ -31,7 +31,7 @@ module.exports = class TodayCommand extends Command { .setDescription(`${events[randomNumber].text} (${events[randomNumber].year})`); return message.embed(embed); } catch (err) { - return message.say(':x: Error! Something went wrong!'); + return message.say('An Unknown Error Occurred.'); } } }; diff --git a/commands/random/wouldyourather.js b/commands/random/wouldyourather.js index 0b26639f..c751bdca 100644 --- a/commands/random/wouldyourather.js +++ b/commands/random/wouldyourather.js @@ -18,7 +18,7 @@ module.exports = class WouldYouRatherCommand extends Command { async run(message) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) - return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + return message.say('This Command requires the `Embed Links` Permission.'); try { const { body } = await request .get('http://www.rrrather.com/botapi'); @@ -29,7 +29,7 @@ module.exports = class WouldYouRatherCommand extends Command { .setDescription(`${body.choicea} OR ${body.choiceb}?`); return message.embed(embed); } catch (err) { - return message.say(':x: Error! Something went wrong!'); + return message.say('An Unknown Error Occurred.'); } } }; diff --git a/commands/randomimg/cat.js b/commands/randomimg/cat.js index a94bc776..24f9b36e 100644 --- a/commands/randomimg/cat.js +++ b/commands/randomimg/cat.js @@ -17,7 +17,7 @@ module.exports = class CatCommand extends Command { run(message) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) - return message.say(':x: Error! I don\'t have the Attach Files Permission!'); + return message.say('This Command requires the `Attach Files` Permission.'); const cat = cats[Math.floor(Math.random() * cats.length)]; return message.channel.send({files: [`./images/Cat${cat}`]}); } diff --git a/commands/randomimg/potato.js b/commands/randomimg/potato.js index e813270c..58714822 100644 --- a/commands/randomimg/potato.js +++ b/commands/randomimg/potato.js @@ -17,7 +17,7 @@ module.exports = class PotatoCommand extends Command { run(message) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) - return message.say(':x: Error! I don\'t have the Attach Files Permission!'); + return message.say('This Command requires the `Attach Files` Permission.'); const potato = potatoes[Math.floor(Math.random() * potatoes.length)]; return message.channel.send({files: [`./images/Potato${potato}`]}); } diff --git a/commands/randomimg/pun.js b/commands/randomimg/pun.js index 206e115c..93191b44 100644 --- a/commands/randomimg/pun.js +++ b/commands/randomimg/pun.js @@ -14,7 +14,7 @@ module.exports = class RandomPunCommand extends Command { run(message) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) - return message.say(':x: Error! I don\'t have the Attach Files Permission!'); + return message.say('This Command requires the `Attach Files` Permission.'); const pun = puns[Math.floor(Math.random() * puns.length)]; return message.channel.send({files: [`./images/Pun${pun}`]}); } diff --git a/commands/randomimg/xiaopai.js b/commands/randomimg/xiaopai.js index a65a43a9..2af74b27 100644 --- a/commands/randomimg/xiaopai.js +++ b/commands/randomimg/xiaopai.js @@ -17,7 +17,7 @@ module.exports = class XiaoCommand extends Command { run(message) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) - return message.say(':x: Error! I don\'t have the Attach Files Permission!'); + return message.say('This Command requires the `Attach Files` Permission.'); const xiao = xiaos[Math.floor(Math.random() * xiaos.length)]; return message.channel.send({files: [`./images/Xiao${xiao}`]}); } diff --git a/commands/search/botinfo.js b/commands/search/botinfo.js index a45f9fee..545130c0 100644 --- a/commands/search/botinfo.js +++ b/commands/search/botinfo.js @@ -20,7 +20,7 @@ module.exports = class BotSearchCommand extends Command { async run(message, args) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) - return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + return message.say('This Command requires the `Embed Links` Permission.'); let { bot } = args; bot = bot.id; try { @@ -43,7 +43,7 @@ module.exports = class BotSearchCommand extends Command { body.prefix, true); return message.embed(embed); } catch (err) { - return message.say(':x: Error! Bot not Found!'); + return message.say('An Error Occurred. The bot may not have been found.'); } } }; diff --git a/commands/search/define.js b/commands/search/define.js index 93a84af1..37b76c85 100644 --- a/commands/search/define.js +++ b/commands/search/define.js @@ -21,7 +21,7 @@ module.exports = class DefineCommand extends Command { async run(message, args) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) - return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + return message.say('This Command requires the `Embed Links` Permission.'); const { word } = args; try { const { body } = await request @@ -33,7 +33,7 @@ module.exports = class DefineCommand extends Command { .setDescription(data.text); return message.embed(embed); } catch (err) { - return message.say(':x: Error! Word not Found!'); + return message.say('An Error Occurred. The word may not have been found.'); } } }; diff --git a/commands/search/discrim.js b/commands/search/discrim.js index 69446d14..0775fc61 100644 --- a/commands/search/discrim.js +++ b/commands/search/discrim.js @@ -28,7 +28,7 @@ module.exports = class DiscrimCommand extends Command { async run(message, args) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) - return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + return message.say('This Command requires the `Embed Links` Permission.'); const { discrim } = args; const users = await this.client.users.filter(u => u.discriminator === discrim).map(u => u.username).sort(); const embed = new RichEmbed() diff --git a/commands/search/forecast.js b/commands/search/forecast.js index 239d71c9..3dcf0d7d 100644 --- a/commands/search/forecast.js +++ b/commands/search/forecast.js @@ -20,7 +20,7 @@ module.exports = class ForecastCommand extends Command { async run(message, args) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) - return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + return message.say('This Command requires the `Embed Links` Permission.'); const { location } = args; try { const { body } = await request @@ -48,7 +48,7 @@ module.exports = class ForecastCommand extends Command { `**High:** ${data[6].high}°F, **Low:** ${data[6].low}°F, **Condition:** ${data[6].text}`); return message.embed(embed); } catch (err) { - return message.say(':x: Error! Make sure you typed the location correctly!'); + return message.say('An Error Occurred. The location may not have been found.'); } } }; diff --git a/commands/search/google.js b/commands/search/google.js index 66553128..2a03c633 100644 --- a/commands/search/google.js +++ b/commands/search/google.js @@ -31,7 +31,7 @@ module.exports = class GoogleCommand extends Command { href = querystring.parse(href.replace('/url?', '')); return msg.edit(href.q); } catch (err) { - return msg.edit(':x: Error! No Results Found!'); + return msg.edit('No Results Found.'); } } }; diff --git a/commands/search/imdb.js b/commands/search/imdb.js index ebf6137e..81936fca 100644 --- a/commands/search/imdb.js +++ b/commands/search/imdb.js @@ -21,7 +21,7 @@ module.exports = class IMDBCommand extends Command { async run(message, args) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) - return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + return message.say('This Command requires the `Embed Links` Permission.'); const { movie } = args; try { const { body } = await request @@ -48,7 +48,7 @@ module.exports = class IMDBCommand extends Command { body.Actors); return message.embed(embed); } catch (err) { - return message.say(':x: Error! Movie not found!'); + return message.say('An Error Occurred. The film may not have been found.'); } } }; diff --git a/commands/search/map.js b/commands/search/map.js index 979c2266..08c24820 100644 --- a/commands/search/map.js +++ b/commands/search/map.js @@ -29,14 +29,14 @@ module.exports = class MapCommand extends Command { async run(message, args) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) - return message.say(':x: Error! I don\'t have the Attach Files Permission!'); + return message.say('This Command requires the `Attach Files` Permission.'); const { zoom, location } = args; try { const { body } = await request .get(`https://maps.googleapis.com/maps/api/staticmap?center=${location}&zoom=${zoom}&size=500x500&key=${process.env.GOOGLE_KEY}`); return message.channel.send({files: [{attachment: body}]}); } catch (err) { - return message.say(':x: Error! Something went wrong! Make sure you entered the location correctly!'); + return message.say('An Error Occurred. The location may not have been found.'); } } }; diff --git a/commands/search/neopet.js b/commands/search/neopet.js index 1aa7ca33..05a7c880 100644 --- a/commands/search/neopet.js +++ b/commands/search/neopet.js @@ -19,9 +19,6 @@ module.exports = class NeopetCommand extends Command { } async run(message, args) { - if (message.channel.type !== 'dm') - if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) - return message.say(':x: Error! I don\'t have the Attach Files Permission!'); const { pet } = args; try { const { text } = await request @@ -29,10 +26,10 @@ module.exports = class NeopetCommand extends Command { const $ = cheerio.load(text); const link = $('textarea').first().text(); if (!link.includes('cp')) - return message.say(':x: Error! Pet not found!'); + return message.say('This is not a valid pet name.'); return message.say(link); } catch (err) { - return message.say(':x: Error! Something went wrong!'); + return message.say('An Unknown Error Occurred.'); } } }; diff --git a/commands/search/osu.js b/commands/search/osu.js index 1546e4f5..d9ae426b 100644 --- a/commands/search/osu.js +++ b/commands/search/osu.js @@ -21,7 +21,7 @@ module.exports = class OsuCommand extends Command { async run(message, args) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) - return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + return message.say('This Command requires the `Embed Links` Permission.'); const { username } = args; try { const { body } = await request @@ -57,7 +57,7 @@ module.exports = class OsuCommand extends Command { data.count_rank_a, true); return message.embed(embed); } catch (err) { - return message.say(':x: Error! User not Found!'); + return message.say('An Error Occurred. The user may not have been found.'); } } }; diff --git a/commands/search/soundcloud.js b/commands/search/soundcloud.js index 61b0db5a..2c0fcb80 100644 --- a/commands/search/soundcloud.js +++ b/commands/search/soundcloud.js @@ -21,7 +21,7 @@ module.exports = class SoundCloudCommand extends Command { async run(message, args) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) - return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + return message.say('This Command requires the `Embed Links` Permission.'); const { query } = args; try { const { body } = await request @@ -44,7 +44,7 @@ module.exports = class SoundCloudCommand extends Command { data.favoritings_count, true); return message.embed(embed); } catch (err) { - return message.say(':x: Error! No Results Found!'); + return message.say('An Error Occurred. The song may not have been found.'); } } }; diff --git a/commands/search/urban.js b/commands/search/urban.js index c613ff86..42638d93 100644 --- a/commands/search/urban.js +++ b/commands/search/urban.js @@ -21,7 +21,7 @@ module.exports = class UrbanCommand extends Command { async run(message, args) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) - return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + return message.say('This Command requires the `Embed Links` Permission.'); const { word } = args; try { const { body } = await request @@ -37,7 +37,7 @@ module.exports = class UrbanCommand extends Command { data.example.substr(0, 2000) || 'None'); return message.embed(embed); } catch (err) { - return message.say(':x: Error! Word not found!'); + return message.say('An Error Occurred. The word may not have been found.'); } } }; diff --git a/commands/search/wattpad.js b/commands/search/wattpad.js index 490290af..04fd4c8e 100644 --- a/commands/search/wattpad.js +++ b/commands/search/wattpad.js @@ -21,7 +21,7 @@ module.exports = class WattpadCommand extends Command { async run(message, args) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) - return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + return message.say('This Command requires the `Embed Links` Permission.'); const { book } = args; try { const { body } = await request @@ -50,7 +50,7 @@ module.exports = class WattpadCommand extends Command { data.commentCount, true); return message.embed(embed); } catch (err) { - return message.say(':x: Error! Book not Found!'); + return message.say('An Error Occurred. The book may not have been found.'); } } }; diff --git a/commands/search/weather.js b/commands/search/weather.js index 21a6778e..318aa18d 100644 --- a/commands/search/weather.js +++ b/commands/search/weather.js @@ -20,7 +20,7 @@ module.exports = class WeatherCommand extends Command { async run(message, args) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) - return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + return message.say('This Command requires the `Embed Links` Permission.'); const { location } = args; try { const { body } = await request @@ -57,7 +57,7 @@ module.exports = class WeatherCommand extends Command { data.wind.speed, true); return message.embed(embed); } catch (err) { - return message.say(':x: Error! Make sure you typed the location correctly!'); + return message.say('An Error Occurred. The location may not have been found.'); } } }; diff --git a/commands/search/wikipedia.js b/commands/search/wikipedia.js index e10633c9..65b11297 100644 --- a/commands/search/wikipedia.js +++ b/commands/search/wikipedia.js @@ -21,7 +21,7 @@ module.exports = class WikipediaCommand extends Command { async run(message, args) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) - return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + return message.say('This Command requires the `Embed Links` Permission.'); const { query } = args; try { const { body } = await request @@ -36,7 +36,7 @@ module.exports = class WikipediaCommand extends Command { .setDescription(description); return message.embed(embed); } catch (err) { - return message.say(':x: Error! Entry Not Found!'); + return message.say('An Error Occurred. The page may not have been found.'); } } }; diff --git a/commands/search/youtube.js b/commands/search/youtube.js index f694d18b..018cb962 100644 --- a/commands/search/youtube.js +++ b/commands/search/youtube.js @@ -21,7 +21,7 @@ module.exports = class YouTubeCommand extends Command { async run(message, args) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) - return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + return message.say('This Command requires the `Embed Links` Permission.'); const { video } = args; try { const { body } = await request @@ -36,7 +36,7 @@ module.exports = class YouTubeCommand extends Command { .setThumbnail(data.snippet.thumbnails.default.url); return message.embed(embed); } catch (err) { - return message.say(':x: Error! Something went wrong! Maybe no video was found?'); + return message.say('An Error Occurred. The video may not have been found.'); } } }; diff --git a/commands/search/yugioh.js b/commands/search/yugioh.js index 92b72e73..92be9f54 100644 --- a/commands/search/yugioh.js +++ b/commands/search/yugioh.js @@ -21,7 +21,7 @@ module.exports = class YuGiOhCommand extends Command { async run(message, args) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) - return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + return message.say('This Command requires the `Embed Links` Permission.'); const { card } = args; try { const { body } = await request @@ -56,7 +56,7 @@ module.exports = class YuGiOhCommand extends Command { data.card_type, true); return message.embed(embed); } catch (err) { - return message.say(':x: Error! Card not Found!\n:notepad_spiral: Note: This command is **extremely** sensitive to casing and dashes and whatnot. Type the *exact* card name to get data!'); + return message.say('An Error Occurred. The card may not have been found.'); } } }; diff --git a/commands/textedit/embed.js b/commands/textedit/embed.js index 71c22ab2..6ebcfb7f 100644 --- a/commands/textedit/embed.js +++ b/commands/textedit/embed.js @@ -19,7 +19,7 @@ module.exports = class EmbedCommand extends Command { run(message, args) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) - return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + return message.say('This Command requires the `Embed Links` Permission.'); const { text } = args; const embed = new RichEmbed() .setAuthor(message.author.username, message.author.avatarURL) diff --git a/commands/textedit/say.js b/commands/textedit/say.js index 297ad2f4..27d829f9 100644 --- a/commands/textedit/say.js +++ b/commands/textedit/say.js @@ -12,6 +12,7 @@ module.exports = class SayCommand extends Command { group: 'textedit', memberName: 'say', description: 'Make XiaoBot say what you wish.', + guildOnly: true, args: [{ key: 'text', prompt: 'What text would you like XiaoBot to say?', @@ -21,7 +22,10 @@ module.exports = class SayCommand extends Command { } run(message, args) { + if (!message.channel.permissionsFor(this.client.user).hasPermission('MANAGE_MESSAGES')) + return message.say('This Command requires the `Manage Messages` Permission.'); const { text } = args; + message.delete(); return message.say(`\u180E${text}`); } }; diff --git a/commands/textedit/webhook.js b/commands/textedit/webhook.js index 3f8e35f2..74f21d04 100644 --- a/commands/textedit/webhook.js +++ b/commands/textedit/webhook.js @@ -27,7 +27,7 @@ module.exports = class WebhookCommand extends Command { async run(message, args) { if (!message.channel.permissionsFor(this.client.user).hasPermission('MANAGE_MESSAGES')) - return message.say(':x: Error! I don\'t have the Manage Messages Permission!'); + return message.say('This Command requires the `Manage Messages` Permission.'); const { text } = args; try { message.delete(); @@ -38,7 +38,7 @@ module.exports = class WebhookCommand extends Command { }); return null; } catch (err) { - return message.say(':x: Error! Message failed to send!'); + return message.say('An Unknown Error Occurred.'); } } }; diff --git a/commands/userinfo/userinfo.js b/commands/userinfo/userinfo.js index 367afe5a..fe86f0cd 100644 --- a/commands/userinfo/userinfo.js +++ b/commands/userinfo/userinfo.js @@ -27,7 +27,7 @@ module.exports = class UserInfoCommand extends Command { async run(message, args) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) - return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + return message.say('This Command requires the `Embed Links` Permission.'); const { user } = args; const member = await message.guild.fetchMember(user); let stat; diff --git a/commands/util/info.js b/commands/util/info.js index cc9ce6c5..1b29cf41 100644 --- a/commands/util/info.js +++ b/commands/util/info.js @@ -20,7 +20,7 @@ module.exports = class InfoCommand extends Command { async run(message) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) - return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + return message.say('This Command requires the `Embed Links` Permission.'); const guilds = await this.client.shard.fetchClientValues('guilds.size'); const embed = new RichEmbed() .setColor(0x00AE86) diff --git a/commands/util/shardinfo.js b/commands/util/shardinfo.js index 8e82fc41..7972bbef 100644 --- a/commands/util/shardinfo.js +++ b/commands/util/shardinfo.js @@ -25,10 +25,10 @@ module.exports = class ShardInfoCommand extends Command { async run(message, args) { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) - return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + return message.say('This Command requires the `Embed Links` Permission.'); const { shardID } = args; if (shardID > this.client.options.shardCount - 1 || shardID < 0) - return message.say(':x: Error! Invalid Shard!'); + return message.say('The Shard ID is not valid.'); const memory = await this.client.shard.broadcastEval('Math.round(process.memoryUsage().heapUsed / 1024 / 1024)'); const uptime = await this.client.shard.fetchClientValues('uptime'); const guilds = await this.client.shard.fetchClientValues('guilds.size'); diff --git a/package.json b/package.json index 4fe77542..5b24ca46 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "15.3.19", + "version": "15.3.20", "description": "A Discord Bot", "main": "shardingmanager.js", "scripts": {