diff --git a/commands/avataredit/3000years.js b/commands/avataredit/3000years.js index 341591a7..28d49390 100644 --- a/commands/avataredit/3000years.js +++ b/commands/avataredit/3000years.js @@ -25,7 +25,7 @@ module.exports = class YearsCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) return message.say(':x: Error! I don\'t have the Attach Files Permission!'); } - const user = args.user; + const { user } = args; let userAvatar = user.displayAvatarURL; userAvatar = userAvatar.replace('.jpg', '.png'); userAvatar = userAvatar.replace('.gif', '.png'); diff --git a/commands/avataredit/beautiful.js b/commands/avataredit/beautiful.js index e40ac752..e2a528b0 100644 --- a/commands/avataredit/beautiful.js +++ b/commands/avataredit/beautiful.js @@ -25,7 +25,7 @@ module.exports = class BeautifulCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) return message.say(':x: Error! I don\'t have the Attach Files Permission!'); } - const user = args.user; + const { user } = args; let userAvatar = user.displayAvatarURL; userAvatar = userAvatar.replace('.jpg', '.png'); userAvatar = userAvatar.replace('.gif', '.png'); diff --git a/commands/avataredit/bobross.js b/commands/avataredit/bobross.js index 7ef805e8..f9ffa82a 100644 --- a/commands/avataredit/bobross.js +++ b/commands/avataredit/bobross.js @@ -26,7 +26,7 @@ module.exports = class BobRossCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) return message.say(':x: Error! I don\'t have the Attach Files Permission!'); } - const user = args.user; + const { user } = args; let userAvatar = user.displayAvatarURL; userAvatar = userAvatar.replace('.jpg', '.png'); userAvatar = userAvatar.replace('.gif', '.png'); diff --git a/commands/avataredit/rip.js b/commands/avataredit/rip.js index 6d3892f5..a0d994cd 100644 --- a/commands/avataredit/rip.js +++ b/commands/avataredit/rip.js @@ -26,7 +26,7 @@ module.exports = class RIPCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) return message.say(':x: Error! I don\'t have the Attach Files Permission!'); } - const user = args.user; + const { user } = args; let userAvatar = user.displayAvatarURL; userAvatar = userAvatar.replace('.jpg', '.png'); userAvatar = userAvatar.replace('.gif', '.png'); diff --git a/commands/avataredit/steamcard.js b/commands/avataredit/steamcard.js index 9c3081ce..7beb25da 100644 --- a/commands/avataredit/steamcard.js +++ b/commands/avataredit/steamcard.js @@ -25,7 +25,7 @@ module.exports = class SteamCardCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) return message.say(':x: Error! I don\'t have the Attach Files Permission!'); } - const user = args.user; + const { user } = args; const userDisplayName = user.username; let userAvatar = user.displayAvatarURL; userAvatar = userAvatar.replace('.jpg', '.png'); diff --git a/commands/games/mathgame.js b/commands/games/mathgame.js index 71251aba..f81f776c 100644 --- a/commands/games/mathgame.js +++ b/commands/games/mathgame.js @@ -19,6 +19,9 @@ module.exports = class MathGameCommand extends Command { return true; } return 'Please set the difficulty to either `easy`, `medium`, `hard`, or `extreme`.'; + }, + parse: text => { + return text.toLowerCase(); } }] }); @@ -29,11 +32,11 @@ module.exports = class MathGameCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } - const level = args.difficulty.toLowerCase(); + const { difficulty } = args; let operation = ['+', '-', '*']; operation = operation[Math.floor(Math.random() * operation.length)]; let value; - switch (level) { + switch (difficulty) { case 'easy': value = 10; break; diff --git a/commands/games/rockpaperscissors.js b/commands/games/rockpaperscissors.js index 77272b74..bb42e713 100644 --- a/commands/games/rockpaperscissors.js +++ b/commands/games/rockpaperscissors.js @@ -20,6 +20,9 @@ module.exports = class RockPaperScissorsCommand extends Command { return true; } return 'Please enter either `rock`, `paper`, or `scissors`.'; + }, + parse: text => { + return text.toLowerCase(); } }] }); @@ -29,18 +32,18 @@ module.exports = class RockPaperScissorsCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const rps = args.choice.toLowerCase(); + const { choice } = args; let response = ['Paper', 'Rock', 'Scissors']; response = response[Math.floor(Math.random() * response.length)]; - if (rps === 'rock') { + if (choice === 'rock') { if (response === 'Rock') return message.say('Rock! Aw, it\'s a tie!'); if (response === 'Paper') return message.say('Paper! Yes! I win!'); if (response === 'Scissors') return message.say('Scissors! Aw... I lose...'); - } else if (rps === 'paper') { + } else if (choice === 'paper') { if (response === 'Rock') return message.say('Rock! Aw... I lose...'); if (response === 'Paper') return message.say('Paper! Aw, it\'s a tie!'); if (response === 'Scissors') return message.say('Scissors! Yes! I win!'); - } else if (rps === 'scissors') { + } else if (choice === 'scissors') { if (response === 'Rock') return message.say('Rock! Yes! I win!'); if (response === 'Paper') return message.say('Paper! Aw... I lose...'); if (response === 'Scissors') return message.say('Scissors! Aw, it\'s a tie!'); diff --git a/commands/games/typinggame.js b/commands/games/typinggame.js index 85513585..d2809404 100644 --- a/commands/games/typinggame.js +++ b/commands/games/typinggame.js @@ -18,6 +18,9 @@ module.exports = class TypingGameCommand extends Command { return true; } return 'Please set the difficulty to either `easy`, `medium`, `hard`, or `extreme`.'; + }, + parse: text => { + return text.toLowerCase(); } }] }); @@ -28,12 +31,12 @@ module.exports = class TypingGameCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } - const level = args.difficulty.toLowerCase(); + const { difficulty } = args; let sentence = ['The quick brown fox jumps over the lazy dog.', 'Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo.', 'How razorback-jumping frogs can level six piqued gymnasts!', 'Amazingly few discotheques provide jukeboxes.']; sentence = sentence[Math.floor(Math.random() * sentence.length)]; let time; let levelWord; - switch (level) { + switch (difficulty) { case 'easy': time = 25000; levelWord = 'twenty-five'; diff --git a/commands/imageedit/meme.js b/commands/imageedit/meme.js index 1773e2e4..24d3a136 100644 --- a/commands/imageedit/meme.js +++ b/commands/imageedit/meme.js @@ -22,6 +22,9 @@ module.exports = class MemeCommand extends Command { return true; } return 'Please enter a valid meme type. Use `;help meme` to view a list of types.'; + }, + parse: text => { + return text.toLowerCase(); } }, { key: 'toprow', @@ -32,6 +35,9 @@ module.exports = class MemeCommand extends Command { return true; } return 'Please do not use special characters and keep the rows under 100 characters each.'; + }, + parse: text => { + return text.replace(/[ ]/g, '-').replace(/[?]/g, '~q'); } }, { key: 'bottomrow', @@ -42,6 +48,9 @@ module.exports = class MemeCommand extends Command { return true; } return 'Please do not use special characters and keep the rows under 100 characters each.'; + }, + parse: text => { + return text.replace(/[ ]/g, '-').replace(/[?]/g, '~q'); } }] }); @@ -52,11 +61,7 @@ module.exports = class MemeCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) return message.say(':x: Error! I don\'t have the Attach Files Permission!'); } - const type = args.type.toLowerCase(); - let toprow = args.toprow.replace(/[ ]/g, '-'); - toprow = toprow.replace(/[?]/g, '~q'); - let bottomrow = args.bottomrow.replace(/[ ]/g, '-'); - bottomrow = bottomrow.replace(/[?]/g, '~q'); + const { type, toprow, bottomrow } = args; const link = `https://memegen.link/${type}/${toprow}/${bottomrow}.jpg`; return message.channel.send({file: link}).catch(() => message.say(':x: Error! Something went wrong!')); } diff --git a/commands/moderation/ban.js b/commands/moderation/ban.js index d6e1b25f..6ea0de74 100644 --- a/commands/moderation/ban.js +++ b/commands/moderation/ban.js @@ -16,7 +16,7 @@ module.exports = class BanCommand extends Command { args: [{ key: 'member', prompt: 'What member do you want to ban?', - type: 'user' + type: 'member' }, { key: 'reason', prompt: 'What do you want to set the reason as?', @@ -42,9 +42,7 @@ module.exports = class BanCommand extends Command { 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.guild.channels.exists('name', 'mod_logs')) return message.say(':x: Error! Could not find the mod_logs channel! Please create it!'); - let member = message.guild.member(args.member); - if (!member) member = await message.guild.fetchMember(args.member); - const reason = args.reason; + 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?'); try { await member.ban(7); diff --git a/commands/moderation/kick.js b/commands/moderation/kick.js index f7253686..313ed56f 100644 --- a/commands/moderation/kick.js +++ b/commands/moderation/kick.js @@ -13,7 +13,7 @@ module.exports = class KickCommand extends Command { args: [{ key: 'member', prompt: 'What member do you want to kick?', - type: 'user' + type: 'member' }, { key: 'reason', prompt: 'What do you want to set the reason as?', @@ -39,9 +39,7 @@ module.exports = class KickCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission('KICK_MEMBERS')) return message.say(':x: Error! I don\'t have the Kick Members Permission!'); } if (!message.guild.channels.exists('name', 'mod_logs')) return message.say(':x: Error! Could not find the mod_logs channel! Please create it!'); - let member = message.guild.member(args.member); - if (!member) member = await message.guild.fetchMember(args.member); - const reason = args.reason; + 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?'); try { await member.kick(); diff --git a/commands/moderation/lockdown.js b/commands/moderation/lockdown.js index 90417d03..18ec378c 100644 --- a/commands/moderation/lockdown.js +++ b/commands/moderation/lockdown.js @@ -18,6 +18,9 @@ module.exports = class LockdownCommand extends Command { return true; } return 'Please enter either start or stop.'; + }, + parse: text => { + return text.toLowerCase(); } }] }); @@ -32,7 +35,7 @@ module.exports = class LockdownCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission(['READ_MESSAGES', 'SEND_MESSAGES'])) return; if (!message.channel.permissionsFor(this.client.user).hasPermission('ADMINISTRATOR')) return message.say(':x: Error! I don\'t have the Administrator permission! This is not given by default, as that\'s quite bad practice. Please give it to me to use the lockdown command!'); } - const type = args.type.toLowerCase(); + const { type } = args; if (type === 'start') { try { await message.channel.overwritePermissions(message.guild.defaultRole, { diff --git a/commands/moderation/prune.js b/commands/moderation/prune.js index 3a2cc892..7334d22e 100644 --- a/commands/moderation/prune.js +++ b/commands/moderation/prune.js @@ -30,6 +30,9 @@ module.exports = class PruneCommand extends Command { return true; } return 'Too many or two few messages to delete. Limit 1-99.'; + }, + parse: count => { + return count + 1; } }] }); @@ -45,7 +48,7 @@ module.exports = class PruneCommand extends Command { 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!'); if (!message.channel.permissionsFor(this.client.user).hasPermission('MANAGE_MESSAGES')) return message.say(':x: Error! I don\'t have the Manage Messages Permission!'); } - const count = args.count + 1; + const { count } = args; try { const messages = await message.channel.fetchMessages({ limit: count diff --git a/commands/moderation/unban.js b/commands/moderation/unban.js index 42407780..e9a1b44f 100644 --- a/commands/moderation/unban.js +++ b/commands/moderation/unban.js @@ -48,8 +48,7 @@ module.exports = class UnbanCommand extends Command { 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.guild.channels.exists('name', 'mod_logs')) return message.say(':x: Error! Could not find the mod_logs channel! Please create it!'); - const memberID = args.memberID; - const reason = args.reason; + 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.'); const unbanUser = await bans.get(memberID); diff --git a/commands/moderation/warn.js b/commands/moderation/warn.js index 33ece60f..9b2def51 100644 --- a/commands/moderation/warn.js +++ b/commands/moderation/warn.js @@ -13,7 +13,7 @@ module.exports = class WarnCommand extends Command { args: [{ key: 'member', prompt: 'What member do you want to warn?', - type: 'user' + type: 'member' }, { key: 'reason', prompt: 'What do you want to set the reason as?', @@ -37,9 +37,7 @@ module.exports = class WarnCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } - let member = message.guild.member(args.member); - if (!member) member = await message.guild.fetchMember(args.member); - const reason = args.reason; + const { member, reason } = args; if (!message.guild.channels.exists('name', 'mod_logs')) return message.say(':x: Error! Could not find the mod_logs channel! Please create it!'); try { await message.say(':ok_hand:'); diff --git a/commands/random/math.js b/commands/random/math.js index 6e401682..db7cbeb1 100644 --- a/commands/random/math.js +++ b/commands/random/math.js @@ -27,7 +27,7 @@ module.exports = class MathCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const expression = args.expression; + const { expression } = args; try { const solved = math.eval(expression); return message.say(solved).catch(() => message.say(':x: Error! Invalid statement!')); diff --git a/commands/random/motivate.js b/commands/random/motivate.js index b5e8f5db..f2438dc7 100644 --- a/commands/random/motivate.js +++ b/commands/random/motivate.js @@ -15,8 +15,7 @@ module.exports = class MotivateCommand extends Command { args: [{ key: 'thing', prompt: 'What do you want to motivate?', - type: 'string', - default: '' + type: 'string' }] }); } @@ -25,7 +24,7 @@ module.exports = class MotivateCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const motivated = args.thing || message.author; - return message.say(`${motivated}, https://www.youtube.com/watch?v=ZXsQAXx_ao0`); + const { thing } = args; + return message.say(`${thing}, https://www.youtube.com/watch?v=ZXsQAXx_ao0`); } }; diff --git a/commands/random/strawpoll.js b/commands/random/strawpoll.js index e15d9b97..fa671738 100644 --- a/commands/random/strawpoll.js +++ b/commands/random/strawpoll.js @@ -36,8 +36,7 @@ module.exports = class StrawpollCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const title = args.title; - const choices = args.choices; + const { title, choices } = args; if (choices.length < 2) return message.say(':x: Error! You provided less than two choices!'); if (choices.length > 31) return message.say(':x: Error! You provided more than thirty choices!'); try { diff --git a/commands/response/8ball.js b/commands/response/8ball.js index 7bb8c0e7..ab049f9a 100644 --- a/commands/response/8ball.js +++ b/commands/response/8ball.js @@ -20,7 +20,7 @@ module.exports = class MagicBallCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const question = args.question; + const { question } = args; let answer = ['It is certain', 'It is decidedly so', 'Without a doubt', 'Yes definitely', 'You may rely on it', 'As I see it, yes', 'Most likely', 'Outlook good', 'Yes', 'Signs point to yes', 'Reply hazy try again', 'Ask again later', 'Better not tell you now', 'Cannot predict now', 'Concentrate and ask again', 'Don\'t count on it', 'My reply is no', 'My sources say no', 'Outlook not so good', 'Very doubtful']; answer = answer[Math.floor(Math.random() * answer.length)]; return message.say(`Question: ${question}\n:8ball: ${answer} :8ball:`); diff --git a/commands/response/choose.js b/commands/response/choose.js index 4cb09aaa..e015548a 100644 --- a/commands/response/choose.js +++ b/commands/response/choose.js @@ -24,8 +24,8 @@ module.exports = class ChooseCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - let choice = args.choices; - choice = choice[Math.floor(Math.random() * choice.length)]; - return message.say(`I choose ${choice}!`); + let { choices } = args; + choices = choices[Math.floor(Math.random() * choices.length)]; + return message.say(`I choose ${choices}!`); } }; diff --git a/commands/response/compliment.js b/commands/response/compliment.js index 2995ec91..bbbc69eb 100644 --- a/commands/response/compliment.js +++ b/commands/response/compliment.js @@ -11,8 +11,7 @@ module.exports = class ComplimentCommand extends Command { args: [{ key: 'thing', prompt: 'What do you want to compliment?', - type: 'string', - default: '' + type: 'string' }] }); } @@ -21,9 +20,9 @@ module.exports = class ComplimentCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const complimented = args.thing || message.author; + const { thing } = args; let compliment = ['Your smile is contagious.', 'You look great today.', 'You\'re a smart cookie.', 'I bet you make babies smile.', 'You have impeccable manners.', 'I like your style.', 'You have the best laugh.', 'I appreciate you.', 'You are the most perfect you there is.', 'You are enough.', 'You\'re strong.', 'Your perspective is refreshing.', 'You\'re an awesome friend.', 'You light up the room.', 'You shine brighter than a shooting star.', 'You deserve a hug right now.', 'You should be proud of yourself.', 'You\'re more helpful than you realize.', 'You have a great sense of humor.', 'You\'ve got all the right moves!', 'Is that your picture next to \'charming\' in the dictionary?', 'Your kindness is a balm to all who encounter it.', 'You\'re all that and a super-size bag of chips.', 'On a scale from 1 to 10, you\'re an 11.', 'You are brave.', 'You\'re even more beautiful on the inside than you are on the outside.', 'You have the courage of your convictions.', 'Your eyes are breathtaking.', 'If cartoon bluebirds were real, a bunch of them would be sitting on your shoulders singing right now.', 'You are making a difference.', 'You\'re like sunshine on a rainy day.', 'You bring out the best in other people.', 'Your ability to recall random factoids at just the right time is impressive.', 'You\'re a great listener.', 'How is it that you always look great, even in sweatpants?', 'Everything would be better if more people were like you!', 'I bet you sweat glitter.', 'You were cool way before hipsters were cool.', 'That color is perfect on you.', 'Hanging out with you is always a blast.', 'You always know -- and say -- exactly what I need to hear when I need to hear it.', 'You smell really good.', 'You may dance like no one\'s watching, but everyone\'s watching because you\'re an amazing dancer!', 'Being around you makes everything better!', 'When you say, \'I meant to do that,\' I totally believe you.', 'When you\'re not afraid to be yourself is when you\'re most incredible.', 'Colors seem brighter when you\'re around.', 'You\'re more fun than a ball pit filled with candy. (And seriously, what could be more fun than that?)', 'That thing you don\'t like about yourself is what makes you so interesting.', 'You\'re wonderful.', 'You have cute elbows. For reals!', 'Jokes are funnier when you tell them.', 'You\'re better than a triple-scoop ice cream cone. With sprinkles.', 'Your bellybutton is kind of adorable.', 'Your hair looks stunning.', 'You\'re one of a kind!', 'You\'re inspiring.', 'If you were a box of crayons, you\'d be the giant name-brand one with the built-in sharpener.', 'You should be thanked more often. So thank you!!', 'Our community is better because you\'re in it.', 'Someone is getting through something hard right now because you\'ve got their back.', 'You have the best ideas.', 'You always know how to find that silver lining.', 'Everyone gets knocked down sometimes, but you always get back up and keep going.', 'You\'re a candle in the darkness.', 'You\'re a great example to others.', 'Being around you is like being on a happy little vacation.', 'You always know just what to say.', 'You\'re always learning new things and trying to better yourself, which is awesome.', 'If someone based an Internet meme on you, it would have impeccable grammar.', 'You could survive a Zombie apocalypse.', 'You\'re more fun than bubble wrap.', 'When you make a mistake, you fix it.', 'Who raised you? They deserve a medal for a job well done.', 'You\'re great at figuring stuff out.', 'Your voice is magnificent.', 'The people you love are lucky to have you in their lives.', 'You\'re like a breath of fresh air.', 'You\'re gorgeous -- and that\'s the least interesting thing about you, too.', 'You\'re so thoughtful.', 'Your creative potential seems limitless.', 'Your name suits you to a T.', 'You\'re irresistible when you blush.', 'Actions speak louder than words, and yours tell an incredible story.', 'Somehow you make time stop and fly at the same time.', 'When you make up your mind about something, nothing stands in your way.', 'You seem to really know who you are.', 'Any team would be lucky to have you on it.', 'In high school I bet you were voted \'most likely to keep being awesome.\'', 'I bet you do the crossword puzzle in ink.', 'Babies and small animals probably love you.', 'If you were a scented candle they\'d call it Perfectly Imperfect (and it would smell like summer).', 'There\'s ordinary, and then there\'s you.', 'You\'re someone\'s reason to smile.', 'You\'re even better than a unicorn, because you\'re real.', 'How do you keep being so funny and making everyone laugh?', 'You have a good head on your shoulders.', 'Has anyone ever told you that you have great posture?', 'The way you treasure your loved ones is incredible.', 'You\'re really something special.', 'You\'re a gift to those around you.', 'You don\'t deserve it.']; compliment = compliment[Math.floor(Math.random() * compliment.length)]; - return message.say(`${complimented}, ${compliment}`); + return message.say(`${thing}, ${compliment}`); } }; diff --git a/commands/response/name.js b/commands/response/name.js index e6143170..e007ff06 100644 --- a/commands/response/name.js +++ b/commands/response/name.js @@ -21,6 +21,9 @@ module.exports = class RandomNameCommand extends Command { return true; } return 'Please enter either `male` or `female`.'; + }, + parse: text => { + return text.toLowerCase(); } }] }); @@ -30,7 +33,7 @@ module.exports = class RandomNameCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const gender = args.gender.toLowerCase(); + const { gender } = args; let lastName = ['Walker', 'Tworni', 'Ross', 'Smith', 'Odendahl', 'Deere', 'Brown', 'Williams', 'Jones', 'Miles', 'Moss', 'Roberto', 'McFly', 'McDonald', 'Lewis', 'Armstrong', 'Stevenson', 'Schwarzenegger', 'Robinson', 'Parker', 'Piper', 'Johnson', 'Brantley', 'Stewart', 'Ree', 'Talbot', 'Seville', 'Peace', 'Spielberg', 'Baggins', 'Wilborn', 'Vankirk', 'Shireman', 'Jimerson', 'Masters', 'Hack', 'Satcher', 'Younkin', 'Aguila', 'Duffey', 'Burgin', 'Highfall', 'Wee', 'Solari', 'Tomaselli', 'Basler', 'Difranco', 'Latch', 'Rives', 'Dolan', 'Abraham', 'Holter', 'Portugal', 'Lininger', 'Holst', 'Mccroy', 'Follmer', 'Hotchkiss', 'Gassaway', 'Wang', 'Agron', 'Raasch', 'Gourd', 'Czaja', 'Marquart', 'Papadopoulos', 'Ringer', 'Lax', 'Sperling', 'Galusha', 'Alston']; lastName = lastName[Math.floor(Math.random() * lastName.length)]; if (gender === 'male') { diff --git a/commands/response/ratewaifu.js b/commands/response/ratewaifu.js index 42834d09..5d0e638c 100644 --- a/commands/response/ratewaifu.js +++ b/commands/response/ratewaifu.js @@ -23,7 +23,7 @@ module.exports = class RateWaifuCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const waifu = args.waifu; + const { waifu } = args; const rating = Math.floor(Math.random() * 10) + 1; return message.say(`I'd give ${waifu} a ${rating}/10!`); } diff --git a/commands/response/roast.js b/commands/response/roast.js index ed9c9ab4..a99f3e48 100644 --- a/commands/response/roast.js +++ b/commands/response/roast.js @@ -14,8 +14,7 @@ module.exports = class RoastCommand extends Command { args: [{ key: 'thing', prompt: 'What do you want to roast?', - type: 'string', - default: '' + type: 'string' }] }); } @@ -24,9 +23,9 @@ module.exports = class RoastCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const roasted = args.thing || message.author; + const { thing } = args; let roast = ['*puts you in the oven*', 'You\'re so stupid.', 'Sorry, I can\'t hear you over how annoying you are.', 'I\'ve got better things to do.', 'You\'re as dumb as Cleverbot.', 'Your IQ is lower than the Mariana Trench.', 'You\'re so annoying even the flies stay away from your stench.', 'Go away, please.', 'I\'d give you a nasty look but you\'ve already got one.', 'It looks like your face caught fire and someone tried to put it out with a hammer.', 'Your family tree must be a cactus because everyone on it is a prick.', 'Someday you will go far, and I hope you stay there.', 'The zoo called. They\'re wondering how you got out of your cage.', 'I was hoping for a battle of wits, but you appear to be unarmed.', 'You are proof that evolution can go in reverse.', 'Brains aren\'t everything, in your case, they\'re nothing.', 'Sorry I didn\'t get that, I don\'t speak idiot.', 'Why is it acceptable for you to be an idiot, but not for me to point it out?', 'We all sprang from apes, but you did not spring far enough.', 'You\'re an unknown command.', 'If you could go anywhere I chose, I\'d choose dead.', 'Even monkeys can go to space, so clearly you lack some potential.', 'It\'s brains over brawn, yet you have neither.', 'You look like a monkey, and you smell like one too.', 'Even among idiots you\'re lacking.', 'You fail even when you\'re doing absolutely nothing.', 'If there was a vote for \'least likely to succeed\' you\'d win first prize.', 'I\'m surrounded by idiots... Or, wait, that\'s just you.', 'I wanna go home. Well, really I just want to get away from the awful aroma you\'ve got going there.', 'Every time you touch me I have to go home and wash all my clothes nine times just to get a normal smell back.', 'If I had a dollar for every brain you don\'t have, I\'d have one dollar.', 'I\'d help you succeed but you\'re incapable.', 'Your hairline is built like a graph chart, positive and negative forces attract but the clippers and your hair repel', 'I know a good joke! You!']; roast = roast[Math.floor(Math.random() * roast.length)]; - return message.say(`${roasted}, ${roast}`); + return message.say(`${thing}, ${roast}`); } }; diff --git a/commands/response/roll.js b/commands/response/roll.js index 35617a1c..497bd569 100644 --- a/commands/response/roll.js +++ b/commands/response/roll.js @@ -13,10 +13,9 @@ module.exports = class RollCommand extends Command { description: 'Rolls a Dice of your choice. (;roll 6)', examples: [';roll 6'], args: [{ - key: 'number', + key: 'value', prompt: 'Which number do you want to roll?', - type: 'integer', - default: 6 + type: 'integer' }] }); } @@ -25,7 +24,7 @@ module.exports = class RollCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const value = args.number; + const { value } = args; const roll = Math.floor(Math.random() * value) + 1; return message.say(`You rolled a ${roll}.`); } diff --git a/commands/response/ship.js b/commands/response/ship.js index 37515c69..0df34e92 100644 --- a/commands/response/ship.js +++ b/commands/response/ship.js @@ -23,8 +23,8 @@ module.exports = class ShipCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const shipped = args.things; + const { things } = args; const percentage = Math.floor(Math.random() * 100) + 1; - return message.say(`I'd give ${shipped} a ${percentage}%!`); + return message.say(`I'd give ${things} a ${percentage}%!`); } }; diff --git a/commands/roleplay/cuddle.js b/commands/roleplay/cuddle.js index 370eb92e..463e4380 100644 --- a/commands/roleplay/cuddle.js +++ b/commands/roleplay/cuddle.js @@ -20,7 +20,7 @@ module.exports = class CuddleCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const roleplayed = args.thing; - return message.say(`${message.author} *cuddles* ${roleplayed}`); + const { thing } = args; + return message.say(`${message.author} *cuddles* ${thing}`); } }; diff --git a/commands/roleplay/divorce.js b/commands/roleplay/divorce.js index 8b312521..d8ea1fe0 100644 --- a/commands/roleplay/divorce.js +++ b/commands/roleplay/divorce.js @@ -20,7 +20,7 @@ module.exports = class DivorceCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const roleplayed = args.thing; - return message.say(`${message.author} *divorces* ${roleplayed}`); + const { thing } = args; + return message.say(`${message.author} *divorces* ${thing}`); } }; diff --git a/commands/roleplay/eat.js b/commands/roleplay/eat.js index 262028f5..dacc9891 100644 --- a/commands/roleplay/eat.js +++ b/commands/roleplay/eat.js @@ -20,7 +20,7 @@ module.exports = class EatCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const roleplayed = args.thing; - return message.say(`${message.author} *eats* ${roleplayed}`); + const { thing } = args; + return message.say(`${message.author} *eats* ${thing}`); } }; diff --git a/commands/roleplay/falconpunch.js b/commands/roleplay/falconpunch.js index f1649965..9042cb32 100644 --- a/commands/roleplay/falconpunch.js +++ b/commands/roleplay/falconpunch.js @@ -20,7 +20,7 @@ module.exports = class FalconPunchCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const roleplayed = args.thing; - return message.say(`${message.author} *falcon punches* ${roleplayed}`); + const { thing } = args; + return message.say(`${message.author} *falcon punches* ${thing}`); } }; diff --git a/commands/roleplay/fistbump.js b/commands/roleplay/fistbump.js index befdc9ec..c34b7e79 100644 --- a/commands/roleplay/fistbump.js +++ b/commands/roleplay/fistbump.js @@ -20,7 +20,7 @@ module.exports = class FistBumpCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const roleplayed = args.thing; - return message.say(`${message.author} *fist-bumps* ${roleplayed} *badalalala*`); + const { thing } = args; + return message.say(`${message.author} *fist-bumps* ${thing} *badalalala*`); } }; diff --git a/commands/roleplay/highfive.js b/commands/roleplay/highfive.js index 98bc81ad..a4930245 100644 --- a/commands/roleplay/highfive.js +++ b/commands/roleplay/highfive.js @@ -20,7 +20,7 @@ module.exports = class HighFivesCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const roleplayed = args.thing; - return message.say(`${message.author} *high-fives* ${roleplayed}`); + const { thing } = args; + return message.say(`${message.author} *high-fives* ${thing}`); } }; diff --git a/commands/roleplay/hitwithshovel.js b/commands/roleplay/hitwithshovel.js index 36b93e1f..af5b19d3 100644 --- a/commands/roleplay/hitwithshovel.js +++ b/commands/roleplay/hitwithshovel.js @@ -20,7 +20,7 @@ module.exports = class HitwithShovelCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const roleplayed = args.thing; - return message.say(`${message.author} *hits* ${roleplayed} *with a shovel*`); + const { thing } = args; + return message.say(`${message.author} *hits* ${thing} *with a shovel*`); } }; diff --git a/commands/roleplay/hug.js b/commands/roleplay/hug.js index 8a5e71cd..b76e84bc 100644 --- a/commands/roleplay/hug.js +++ b/commands/roleplay/hug.js @@ -20,7 +20,7 @@ module.exports = class HugCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const roleplayed = args.thing; - return message.say(`${message.author} *hugs* ${roleplayed}`); + const { thing } = args; + return message.say(`${message.author} *hugs* ${thing}`); } }; diff --git a/commands/roleplay/inhales.js b/commands/roleplay/inhales.js index 5da7180d..735f5698 100644 --- a/commands/roleplay/inhales.js +++ b/commands/roleplay/inhales.js @@ -20,7 +20,7 @@ module.exports = class InhaleCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const roleplayed = args.thing; - return message.say(`${message.author} *inhales* ${roleplayed} *but gained no ability...*`); + const { thing } = args; + return message.say(`${message.author} *inhales* ${thing} *but gained no ability...*`); } }; diff --git a/commands/roleplay/kill.js b/commands/roleplay/kill.js index da519eef..047328d7 100644 --- a/commands/roleplay/kill.js +++ b/commands/roleplay/kill.js @@ -20,7 +20,7 @@ module.exports = class KillCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const roleplayed = args.thing; - return message.say(`${message.author} *kills* ${roleplayed}`); + const { thing } = args; + return message.say(`${message.author} *kills* ${thing}`); } }; diff --git a/commands/roleplay/kiss.js b/commands/roleplay/kiss.js index 03ee6a5e..75b29c0b 100644 --- a/commands/roleplay/kiss.js +++ b/commands/roleplay/kiss.js @@ -20,7 +20,7 @@ module.exports = class KissCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const roleplayed = args.thing; - return message.say(`${message.author} *kisses* ${roleplayed}`); + const { thing } = args; + return message.say(`${message.author} *kisses* ${thing}`); } }; diff --git a/commands/roleplay/marries.js b/commands/roleplay/marries.js index 0ef29d94..4389dd90 100644 --- a/commands/roleplay/marries.js +++ b/commands/roleplay/marries.js @@ -20,7 +20,7 @@ module.exports = class MarryCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const roleplayed = args.thing; - return message.say(`${message.author} *marries* ${roleplayed}`); + const { thing } = args; + return message.say(`${message.author} *marries* ${thing}`); } }; diff --git a/commands/roleplay/pat.js b/commands/roleplay/pat.js index f2cc31eb..e236e255 100644 --- a/commands/roleplay/pat.js +++ b/commands/roleplay/pat.js @@ -20,7 +20,7 @@ module.exports = class PatCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const roleplayed = args.thing; - return message.say(`${message.author} *pats* ${roleplayed}`); + const { thing } = args; + return message.say(`${message.author} *pats* ${thing}`); } }; diff --git a/commands/roleplay/poke.js b/commands/roleplay/poke.js index 3b4cfcce..5e2670a9 100644 --- a/commands/roleplay/poke.js +++ b/commands/roleplay/poke.js @@ -20,7 +20,7 @@ module.exports = class PokeCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const roleplayed = args.thing; - return message.say(`${message.author} *pokes* ${roleplayed}`); + const { thing } = args; + return message.say(`${message.author} *pokes* ${thing}`); } }; diff --git a/commands/roleplay/punch.js b/commands/roleplay/punch.js index ab4faed6..eda8d06a 100644 --- a/commands/roleplay/punch.js +++ b/commands/roleplay/punch.js @@ -20,7 +20,7 @@ module.exports = class PunchCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const roleplayed = args.thing; - return message.say(`${message.author} *punches* ${roleplayed}`); + const { thing } = args; + return message.say(`${message.author} *punches* ${thing}`); } }; diff --git a/commands/roleplay/slap.js b/commands/roleplay/slap.js index af4baf7d..fa72d3e6 100644 --- a/commands/roleplay/slap.js +++ b/commands/roleplay/slap.js @@ -20,7 +20,7 @@ module.exports = class SlapCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const roleplayed = args.thing; - return message.say(`${message.author} *slaps* ${roleplayed}`); + const { thing } = args; + return message.say(`${message.author} *slaps* ${thing}`); } }; diff --git a/commands/search/botinfo.js b/commands/search/botinfo.js index 8d90d6cc..5bf5bd6c 100644 --- a/commands/search/botinfo.js +++ b/commands/search/botinfo.js @@ -17,7 +17,16 @@ module.exports = class BotSearchCommand extends Command { args: [{ key: 'bot', prompt: 'Which bot do you want to get information for?', - type: 'user' + type: 'user', + validate: user => { + if (user.bot) { + return true; + } + return 'Please only use a bot account.'; + }, + parse: bot => { + return bot.id; + } }] }); } @@ -27,7 +36,7 @@ module.exports = class BotSearchCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } - const bot = args.bot.id; + let { bot } = args; try { const response = await request .get(`https://bots.discord.pw/api/bots/${bot}`) diff --git a/commands/search/define.js b/commands/search/define.js index 05442130..b5fcc993 100644 --- a/commands/search/define.js +++ b/commands/search/define.js @@ -19,7 +19,10 @@ module.exports = class DefineCommand extends Command { args: [{ key: 'word', prompt: 'What would you like to define?', - type: 'string' + type: 'string', + parse: text => { + return encodeURIComponent(text); + } }] }); } @@ -29,7 +32,7 @@ module.exports = class DefineCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } - const word = encodeURIComponent(args.word); + const { word } = args; try { const response = await request .get(`http://api.wordnik.com:80/v4/word.json/${word}/definitions?limit=1&includeRelated=false&useCanonical=false&api_key=${process.env.WORDNIK_KEY}`); diff --git a/commands/search/discrim.js b/commands/search/discrim.js index ab903d55..6eaecf68 100644 --- a/commands/search/discrim.js +++ b/commands/search/discrim.js @@ -32,7 +32,7 @@ module.exports = class DiscrimCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } - const discrim = args.discrim; + const { discrim } = args; const users = await this.client.users.filter(u => u.discriminator === discrim).map(u => u.username).sort(); const embed = new RichEmbed() .setTitle(`${users.length} Users with the discriminator: ${discrim}`) diff --git a/commands/search/forecast.js b/commands/search/forecast.js index 37f15958..a4d5a7e9 100644 --- a/commands/search/forecast.js +++ b/commands/search/forecast.js @@ -14,7 +14,7 @@ module.exports = class ForecastCommand extends Command { description: 'Gets the seven-day forecast for a specified location. (;forecast San Francisco)', examples: [';forecast San Francisco'], args: [{ - key: 'locationQ', + key: 'location', prompt: 'What location would you like to get the forecast for?', type: 'string' }] @@ -26,7 +26,7 @@ module.exports = class ForecastCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } - const location = args.locationQ; + const { location } = args; try { const response = 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="${location}")&format=json`); diff --git a/commands/search/google.js b/commands/search/google.js index a07c960b..e3d591d8 100644 --- a/commands/search/google.js +++ b/commands/search/google.js @@ -17,7 +17,10 @@ module.exports = class GoogleCommand extends Command { args: [{ key: 'query', prompt: 'What would you like to search for?', - type: 'string' + type: 'string', + parse: text => { + return encodeURIComponent(text); + } }] }); } @@ -26,7 +29,7 @@ module.exports = class GoogleCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const query = encodeURIComponent(args.query); + const { query } = args; const msg = await message.say('Searching...'); try { const response = await request diff --git a/commands/search/imdb.js b/commands/search/imdb.js index 6b8c9b9f..e7087a28 100644 --- a/commands/search/imdb.js +++ b/commands/search/imdb.js @@ -18,7 +18,10 @@ module.exports = class IMDBCommand extends Command { args: [{ key: 'movie', prompt: 'What movie or TV Show would you like to search for?', - type: 'string' + type: 'string', + parse: text => { + return encodeURIComponent(text); + } }] }); } @@ -28,7 +31,7 @@ module.exports = class IMDBCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } - const movie = encodeURIComponent(args.movie); + const { movie } = args; try { const response = await request .get(`http://www.omdbapi.com/?t=${movie}&plot=full`); diff --git a/commands/search/map.js b/commands/search/map.js index 109444b3..e6bedfa5 100644 --- a/commands/search/map.js +++ b/commands/search/map.js @@ -23,9 +23,12 @@ module.exports = class MapCommand extends Command { return 'Please enter a zoom value from 1-20'; } }, { - key: 'locationQ', + key: 'location', prompt: 'What location you like to get a map image for?', - type: 'string' + type: 'string', + parse: text => { + return encodeURIComponent(text); + } }] }); } @@ -35,8 +38,7 @@ module.exports = class MapCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) return message.say(':x: Error! I don\'t have the Attach Files Permission!'); } - const zoom = args.zoom; - const location = encodeURIComponent(args.locationQ); + const { zoom, location } = args; try { const response = await request .get(`https://maps.googleapis.com/maps/api/staticmap?center=${location}&zoom=${zoom}&size=500x500&key=${process.env.GOOGLE_KEY}`); diff --git a/commands/search/neopet.js b/commands/search/neopet.js index 9bfaf8ee..ad897c0f 100644 --- a/commands/search/neopet.js +++ b/commands/search/neopet.js @@ -13,7 +13,10 @@ module.exports = class NeopetCommand extends Command { args: [{ key: 'pet', prompt: 'What pet would you like to get the image of?', - type: 'string' + type: 'string', + parse: text => { + return encodeURIComponent(text); + } }] }); } @@ -23,7 +26,7 @@ module.exports = class NeopetCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; 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 = encodeURIComponent(args.pet); + const { pet } = args; try { const response = await request .get(`http://www.sunnyneo.com/petimagefinder.php?name=${pet}&size=5&mood=1`); diff --git a/commands/search/osu.js b/commands/search/osu.js index eb62a433..299d2ca2 100644 --- a/commands/search/osu.js +++ b/commands/search/osu.js @@ -18,7 +18,10 @@ module.exports = class OsuCommand extends Command { args: [{ key: 'username', prompt: 'What osu username would you like to search for?', - type: 'string' + type: 'string', + parse: text => { + return encodeURIComponent(text); + } }] }); } @@ -28,7 +31,7 @@ module.exports = class OsuCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } - const username = encodeURIComponent(args.username); + const { username } = args; try { const response = await request .get(`https://osu.ppy.sh/api/get_user?k=${process.env.OSU_KEY}&u=${username}&type=string`); diff --git a/commands/search/urban.js b/commands/search/urban.js index 31057cc9..134ded71 100644 --- a/commands/search/urban.js +++ b/commands/search/urban.js @@ -18,7 +18,10 @@ module.exports = class UrbanCommand extends Command { args: [{ key: 'word', prompt: 'What would you like to define?', - type: 'string' + type: 'string', + parse: text => { + return encodeURIComponent(text); + } }] }); } @@ -28,7 +31,7 @@ module.exports = class UrbanCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } - const word = encodeURIComponent(args.word); + const { word } = args; try { const response = await request .get(`http://api.urbandictionary.com/v0/define?term=${word}`); diff --git a/commands/search/wattpad.js b/commands/search/wattpad.js index 8b021b11..d3b810d8 100644 --- a/commands/search/wattpad.js +++ b/commands/search/wattpad.js @@ -13,7 +13,10 @@ module.exports = class WattpadCommand extends Command { args: [{ key: 'book', prompt: 'What book would you like to search for?', - type: 'string' + type: 'string', + parse: text => { + return encodeURIComponent(text); + } }] }); } @@ -23,7 +26,7 @@ module.exports = class WattpadCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } - const book = encodeURIComponent(args.book); + const { book } = args; try { const response = await request .get(`https://api.wattpad.com:443/v4/stories?query=${book}&limit=1`) diff --git a/commands/search/weather.js b/commands/search/weather.js index 6b87eed8..788c6487 100644 --- a/commands/search/weather.js +++ b/commands/search/weather.js @@ -11,7 +11,7 @@ module.exports = class WeatherCommand extends Command { description: 'Searches weather for a specified location. (;weather San Francisco)', examples: [';weather San Francisco'], args: [{ - key: 'locationQ', + key: 'location', prompt: 'What location would you like to get the current weather for?', type: 'string' }] @@ -23,7 +23,7 @@ module.exports = class WeatherCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } - const location = args.locationQ; + const { location } = args; try { const response = 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="${location}")&format=json`); diff --git a/commands/search/wikipedia.js b/commands/search/wikipedia.js index 4349e32b..bf5c083f 100644 --- a/commands/search/wikipedia.js +++ b/commands/search/wikipedia.js @@ -13,7 +13,10 @@ module.exports = class WikipediaCommand extends Command { args: [{ key: 'query', prompt: 'What would you like to search for?', - type: 'string' + type: 'string', + parse: text => { + return encodeURIComponent(text).replace(/[)]/g, '%29'); + } }] }); } @@ -23,8 +26,7 @@ module.exports = class WikipediaCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } - let query = encodeURIComponent(args.query); - query = query.replace(/[)]/g, '%29'); + const { query } = args; try { const response = await request .get(`https://en.wikipedia.org/w/api.php?action=query&prop=extracts&format=json&titles=${query}&exintro=&explaintext=&redirects=&formatversion=2`); diff --git a/commands/search/youtube.js b/commands/search/youtube.js index f8646c5b..0fffde63 100644 --- a/commands/search/youtube.js +++ b/commands/search/youtube.js @@ -16,7 +16,10 @@ module.exports = class YouTubeCommand extends Command { args: [{ key: 'video', prompt: 'What would you like to search for?', - type: 'string' + type: 'string', + parse: text => { + return encodeURIComponent(text); + } }] }); } @@ -26,7 +29,7 @@ module.exports = class YouTubeCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } - const video = encodeURIComponent(args.video); + const { video } = args; try { const response = await request .get(`https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&maxResults=1&q=${video}&key=${process.env.GOOGLE_KEY}`); diff --git a/commands/search/yugioh.js b/commands/search/yugioh.js index c7c599a5..626bd8d7 100644 --- a/commands/search/yugioh.js +++ b/commands/search/yugioh.js @@ -13,7 +13,10 @@ module.exports = class YuGiOhCommand extends Command { args: [{ key: 'card', prompt: 'What card would you like to get data for?', - type: 'string' + type: 'string', + parse: text => { + return encodeURIComponent(text); + } }] }); } @@ -23,7 +26,7 @@ module.exports = class YuGiOhCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } - const card = encodeURIComponent(args.card); + const { card } = args; try { const response = await request .get(`http://yugiohprices.com/api/card_data/${card}`); diff --git a/commands/textedit/binary.js b/commands/textedit/binary.js index 88b58d5a..ee4a6976 100644 --- a/commands/textedit/binary.js +++ b/commands/textedit/binary.js @@ -25,6 +25,9 @@ module.exports = class BinaryCommand extends Command { return 'Your message content is too long.'; } return true; + }, + parse: text => { + return stringToBinary(text); } }] }); @@ -34,8 +37,7 @@ module.exports = class BinaryCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const text = args.text; - const binary = stringToBinary(text); - return message.say(binary); + const { text } = args; + return message.say(text); } }; diff --git a/commands/textedit/cowsay.js b/commands/textedit/cowsay.js index 2de625d8..57a4813e 100644 --- a/commands/textedit/cowsay.js +++ b/commands/textedit/cowsay.js @@ -26,7 +26,7 @@ module.exports = class CowsayCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const text = args.text; + const { text } = args; return message.code(null, `< ${text} >\n \\ ^__^\n \\ (oO)\\_______\n (__)\\ )\\/\\\n U ||----w |\n || ||`); } }; diff --git a/commands/textedit/embed.js b/commands/textedit/embed.js index 6a726422..63903dfb 100644 --- a/commands/textedit/embed.js +++ b/commands/textedit/embed.js @@ -18,19 +18,19 @@ module.exports = class EmbedCommand extends Command { }); } - async run(message, args) { + run(message, args) { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); if (!message.channel.permissionsFor(this.client.user).hasPermission('MANAGE_MESSAGES')) return message.say(':x: Error! I don\'t have the Manage Messages Permission!'); } - const text = args.text; + const { text } = args; const embed = new RichEmbed() .setAuthor(message.author.username, message.author.avatarURL) .setColor(0x00AE86) .setTimestamp() .setDescription(text); - await message.delete(); + message.delete(); return message.embed(embed); } }; diff --git a/commands/textedit/morse.js b/commands/textedit/morse.js index 6024f90a..b7f3f7c6 100644 --- a/commands/textedit/morse.js +++ b/commands/textedit/morse.js @@ -22,6 +22,9 @@ module.exports = class MorseCommand extends Command { return true; } return 'Your text to encode is too long.'; + }, + parse: text => { + return translator.letterTrans(text.toLowerCase(), dictionary, ' '); } }] }); @@ -31,8 +34,7 @@ module.exports = class MorseCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const text = args.text.toLowerCase(); - const encoded = translator.letterTrans(text, dictionary, ' '); - return message.say(encoded); + const { text } = args; + return message.say(text); } }; diff --git a/commands/textedit/pirate.js b/commands/textedit/pirate.js index a3d4d96b..fc251330 100644 --- a/commands/textedit/pirate.js +++ b/commands/textedit/pirate.js @@ -23,6 +23,9 @@ module.exports = class PirateCommand extends Command { return 'Your message content is too long.'; } return true; + }, + parse: text => { + return translator.wordTrans(text, dictionary); } }] }); @@ -32,8 +35,7 @@ module.exports = class PirateCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const text = args.text; - const pirate = translator.wordTrans(text, dictionary); - return message.say(`\u180E${pirate}`); + const { text } = args; + return message.say(`\u180E${text}`); } }; diff --git a/commands/textedit/reverse.js b/commands/textedit/reverse.js index efcaafd5..f0722426 100644 --- a/commands/textedit/reverse.js +++ b/commands/textedit/reverse.js @@ -11,7 +11,10 @@ module.exports = class ReverseCommand extends Command { args: [{ key: 'text', prompt: 'What text would you like to reverse?', - type: 'string' + type: 'string', + parse: text => { + return text.split('').reverse().join(''); + } }] }); } @@ -20,8 +23,7 @@ module.exports = class ReverseCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const text = args.text; - const reversed = text.split('').reverse().join(''); - return message.say(`\u180E${reversed}`); + const { text } = args; + return message.say(`\u180E${text}`); } }; diff --git a/commands/textedit/say.js b/commands/textedit/say.js index 7c23902f..84c751d4 100644 --- a/commands/textedit/say.js +++ b/commands/textedit/say.js @@ -23,13 +23,13 @@ module.exports = class SayCommand extends Command { }); } - async run(message, args) { + run(message, args) { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; if (!message.channel.permissionsFor(this.client.user).hasPermission('MANAGE_MESSAGES')) return message.say(':x: Error! I don\'t have the Manage Messages Permission!'); } - const text = args.text; - await message.delete(); + const { text } = args; + message.delete(); return message.say(`\u180E${text}`); } }; diff --git a/commands/textedit/temmie.js b/commands/textedit/temmie.js index 45ab24bc..dd42df12 100644 --- a/commands/textedit/temmie.js +++ b/commands/textedit/temmie.js @@ -19,6 +19,9 @@ module.exports = class TemmieCommand extends Command { return 'Your message content is too long.'; } return true; + }, + parse: text => { + return translator.wordTrans(text, dictionary); } }] }); @@ -28,8 +31,7 @@ module.exports = class TemmieCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const text = args.text; - const temmized = translator.wordTrans(text, dictionary); - return message.say(`\u180E${temmized}`); + const { text } = args; + return message.say(`\u180E${text}`); } }; diff --git a/commands/textedit/upsidedown.js b/commands/textedit/upsidedown.js index 65cf65a5..73a3f898 100644 --- a/commands/textedit/upsidedown.js +++ b/commands/textedit/upsidedown.js @@ -17,7 +17,10 @@ module.exports = class UpsideDownCommand extends Command { args: [{ key: 'text', prompt: 'What text would you like to flip upside-down?', - type: 'string' + type: 'string', + parse: text => { + return translator.letterTrans(text, dictionary); + } }] }); } @@ -26,8 +29,7 @@ module.exports = class UpsideDownCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const text = args.text; - const upsideDown = translator.letterTrans(text, dictionary); - return message.say(upsideDown); + const { text } = args; + return message.say(text); } }; diff --git a/commands/textedit/webhook.js b/commands/textedit/webhook.js index ff2e4354..28d18a6e 100644 --- a/commands/textedit/webhook.js +++ b/commands/textedit/webhook.js @@ -31,9 +31,9 @@ module.exports = class WebhookCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; if (!message.channel.permissionsFor(this.client.user).hasPermission('MANAGE_MESSAGES')) return message.say(':x: Error! I don\'t have the Manage Messages Permission!'); } - const text = args.text; + const { text } = args; try { - await message.delete(); + message.delete(); await request .post(process.env.WEBHOOK_URL) .send({ diff --git a/commands/textedit/zalgo.js b/commands/textedit/zalgo.js index ef58a4b1..fa8682ad 100644 --- a/commands/textedit/zalgo.js +++ b/commands/textedit/zalgo.js @@ -18,6 +18,9 @@ module.exports = class ZalgoCommand extends Command { return 'Your message content is too long.'; } return true; + }, + parse: text => { + return zalgo(text); } }] }); @@ -27,8 +30,7 @@ module.exports = class ZalgoCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const text = args.text; - const zalgoified = zalgo(text); - return message.say(`\u180E${zalgoified}`); + const { text } = args; + return message.say(`\u180E${text}`); } }; diff --git a/commands/userinfo/avatar.js b/commands/userinfo/avatar.js index d5977e5f..9ad06d0f 100644 --- a/commands/userinfo/avatar.js +++ b/commands/userinfo/avatar.js @@ -20,7 +20,7 @@ module.exports = class AvatarCommand extends Command { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } - const user = args.user; + const { user } = args; return message.say(user.displayAvatarURL); } }; diff --git a/commands/userinfo/userinfo.js b/commands/userinfo/userinfo.js index cd23ae03..deab205e 100644 --- a/commands/userinfo/userinfo.js +++ b/commands/userinfo/userinfo.js @@ -30,11 +30,8 @@ module.exports = class UserInfoCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } - const user = args.user; - let member = message.guild.member(user); - if (!member) { - member = await message.guild.fetchMember(user); - } + const { user } = args; + const member = await message.guild.fetchMember(user); let stat; let color; switch (user.presence.status) { @@ -55,7 +52,6 @@ module.exports = class UserInfoCommand extends Command { color = 0x808080; break; } - const userGame = user.presence.game ? user.presence.game.name : 'None'; const embed = new RichEmbed() .setColor(color) .setThumbnail(user.displayAvatarURL) @@ -70,7 +66,7 @@ module.exports = class UserInfoCommand extends Command { .addField('**Status:**', stat, true) .addField('**Playing:**', - userGame, true); + user.presence.game ? user.presence.game.name : 'None', true); return message.embed(embed); } }; diff --git a/commands/util/shardinfo.js b/commands/util/shardinfo.js index 3691dce1..caa85cdc 100644 --- a/commands/util/shardinfo.js +++ b/commands/util/shardinfo.js @@ -31,7 +31,7 @@ module.exports = class ShardInfoCommand extends Command { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } - const shardID = args.shardID; + const { shardID } = args; if (shardID > this.client.options.shardCount - 1 || shardID < 0) return message.say(':x: Error! Invalid Shard!'); const memory = await this.client.shard.broadcastEval('Math.round(process.memoryUsage().heapUsed / 1024 / 1024)'); const uptime = await this.client.shard.fetchClientValues('uptime'); diff --git a/package.json b/package.json index f99d1289..620cd9cd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "28.1.0", + "version": "29.0.0", "description": "A Discord Bot", "main": "shardingmanager.js", "scripts": {