From 988912f471b480b9fca0e998c1d4fecb8481293e Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Sat, 29 Apr 2017 19:53:01 +0000 Subject: [PATCH] Change Variable Names, Remove Useless Commands --- commands/avataredit/3000years.js | 10 +++---- commands/avataredit/beautiful.js | 12 ++++----- commands/avataredit/bobross.js | 4 +-- commands/avataredit/rip.js | 10 +++---- commands/avataredit/steamcard.js | 8 +++--- commands/avataredit/triggered.js | 4 +-- commands/games/mathgame.js | 8 +++--- commands/games/quiz.js | 9 +++---- commands/games/rockpaperscissors.js | 6 ++--- commands/games/typinggame.js | 10 ++----- commands/imageedit/meme.js | 32 +++++++++++----------- commands/moderation/ban.js | 2 +- commands/moderation/kick.js | 2 +- commands/moderation/lockdown.js | 2 +- commands/moderation/prune.js | 5 ++-- commands/moderation/unban.js | 20 +++++++------- commands/moderation/warn.js | 2 +- commands/random/canyounot.js | 16 ----------- commands/random/easteregg.js | 2 +- commands/random/eastereggs.json | 5 +++- commands/random/motivate.js | 22 ---------------- commands/random/nitro.js | 2 +- commands/random/slowclap.js | 16 ----------- commands/random/today.js | 12 ++++----- commands/response/coin.js | 4 +-- commands/response/name.js | 2 +- commands/response/quantumcoin.js | 4 +-- commands/response/ship.js | 4 +-- commands/search/botinfo.js | 5 ++-- commands/search/define.js | 13 +++++---- commands/search/forecast.js | 41 ++++++++++++++--------------- commands/search/google.js | 2 +- commands/search/imdb.js | 8 +++--- commands/search/lmgtfy.js | 2 +- commands/search/map.js | 8 +++--- commands/search/neopet.js | 8 +++--- commands/search/osu.js | 33 +++++++++++------------ commands/search/soundcloud.js | 17 ++++++------ commands/search/urban.js | 15 +++++------ commands/search/wattpad.js | 25 +++++++++--------- commands/search/weather.js | 35 ++++++++++++------------ commands/search/wikipedia.js | 6 ++--- commands/search/youtube.js | 17 ++++++------ commands/search/yugioh.js | 29 ++++++++++---------- commands/textedit/binary.js | 8 +++--- commands/textedit/embed.js | 2 +- commands/textedit/morse.js | 4 +-- commands/textedit/pirate.js | 4 +-- commands/textedit/temmie.js | 4 +-- commands/textedit/zalgo.js | 6 ++--- commands/util/shardinfo.js | 19 +++++-------- package.json | 2 +- 52 files changed, 236 insertions(+), 312 deletions(-) delete mode 100644 commands/random/canyounot.js delete mode 100644 commands/random/motivate.js delete mode 100644 commands/random/slowclap.js diff --git a/commands/avataredit/3000years.js b/commands/avataredit/3000years.js index 7abf4378..77b952ac 100644 --- a/commands/avataredit/3000years.js +++ b/commands/avataredit/3000years.js @@ -24,14 +24,14 @@ module.exports = class YearsCommand extends Command { if (!message.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) return message.say('This Command requires the `Attach Files` Permission.'); const { user } = args; - const userAvatar = user.displayAvatarURL.replace(/(png|jpg|jpeg|gif|webp)/, 'png'); + const avatarURL = user.displayAvatarURL.replace(/(png|jpg|jpeg|gif|webp)/, 'png'); let images = []; - images.push(Jimp.read(userAvatar)); + images.push(Jimp.read(avatarURL)); images.push(Jimp.read('https://i.imgur.com/eScwGFS.png')); - const [avatar, years] = await Promise.all(images); + const [avatar, az] = await Promise.all(images); avatar.resize(200, 200); - years.composite(avatar, 461, 127); - years.getBuffer(Jimp.MIME_PNG, (err, buff) => { + az.composite(avatar, 461, 127); + az.getBuffer(Jimp.MIME_PNG, (err, buff) => { 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 86797c29..25f418f9 100644 --- a/commands/avataredit/beautiful.js +++ b/commands/avataredit/beautiful.js @@ -24,16 +24,16 @@ module.exports = class BeautifulCommand extends Command { if (!message.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) return message.say('This Command requires the `Attach Files` Permission.'); const { user } = args; - const userAvatar = user.displayAvatarURL.replace(/(png|jpg|jpeg|gif|webp)/, 'png'); + const avatarURL = user.displayAvatarURL.replace(/(png|jpg|jpeg|gif|webp)/, 'png'); let images = []; - images.push(Jimp.read(userAvatar)); + images.push(Jimp.read(avatarURL)); images.push(Jimp.read('https://i.imgur.com/OOQ9QwQ.jpg')); - const [avatar, beautiful] = await Promise.all(images); + const [avatar, grunkle] = await Promise.all(images); avatar.resize(200, 200); - beautiful.composite(avatar, 432, 42); + grunkle.composite(avatar, 432, 42); avatar.resize(190, 190); - beautiful.composite(avatar, 451, 434); - beautiful.getBuffer(Jimp.MIME_PNG, (err, buff) => { + grunkle.composite(avatar, 451, 434); + grunkle.getBuffer(Jimp.MIME_PNG, (err, buff) => { 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 a13e17a2..27da65c7 100644 --- a/commands/avataredit/bobross.js +++ b/commands/avataredit/bobross.js @@ -24,10 +24,10 @@ module.exports = class BobRossCommand extends Command { if (!message.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) return message.say('This Command requires the `Attach Files` Permission.'); const { user } = args; - const userAvatar = user.displayAvatarURL.replace(/(png|jpg|jpeg|gif|webp)/, 'png'); + const avatarURL = user.displayAvatarURL.replace(/(png|jpg|jpeg|gif|webp)/, 'png'); const blank = new Jimp(600, 775, 0xFFFFFFFF); let images = []; - images.push(Jimp.read(userAvatar)); + images.push(Jimp.read(avatarURL)); images.push(Jimp.read('https://i.imgur.com/7NSiFLd.png')); const [avatar, bob] = await Promise.all(images); avatar.rotate(2); diff --git a/commands/avataredit/rip.js b/commands/avataredit/rip.js index c94a50e4..682f576b 100644 --- a/commands/avataredit/rip.js +++ b/commands/avataredit/rip.js @@ -25,14 +25,14 @@ module.exports = class RIPCommand extends Command { if (!message.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) return message.say('This Command requires the `Attach Files` Permission.'); const { user } = args; - const userAvatar = user.displayAvatarURL.replace(/(png|jpg|jpeg|gif|webp)/, 'png'); + const avatarURL = user.displayAvatarURL.replace(/(png|jpg|jpeg|gif|webp)/, 'png'); let images = []; - images.push(Jimp.read(userAvatar)); + images.push(Jimp.read(avatarURL)); images.push(Jimp.read('https://i.imgur.com/KriteWm.jpg')); - const [avatar, gravestone] = await Promise.all(images); + const [avatar, grave] = await Promise.all(images); avatar.resize(200, 200); - gravestone.composite(avatar, 158, 51); - gravestone.getBuffer(Jimp.MIME_PNG, (err, buff) => { + grave.composite(avatar, 158, 51); + grave.getBuffer(Jimp.MIME_PNG, (err, buff) => { 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 393407c3..c7040530 100644 --- a/commands/avataredit/steamcard.js +++ b/commands/avataredit/steamcard.js @@ -25,16 +25,16 @@ module.exports = class SteamCardCommand extends Command { 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(/(png|jpg|jpeg|gif|webp)/, 'png'); + const avatarURL = user.displayAvatarURL.replace(/(png|jpg|jpeg|gif|webp)/, 'png'); const blank = new Jimp(494, 568, 0xFFFFFFFF); let images = []; - images.push(Jimp.read(userAvatar)); + images.push(Jimp.read(avatarURL)); images.push(Jimp.read('https://i.imgur.com/JF0WwQX.png')); - const [avatar, steamcard] = await Promise.all(images); + const [avatar, card] = await Promise.all(images); const font = await Jimp.loadFont(Jimp.FONT_SANS_32_WHITE); avatar.resize(450, 450); blank.composite(avatar, 25, 25); - blank.composite(steamcard, 0, 0); + blank.composite(card, 0, 0); blank.print(font, 38, 20, username); blank.getBuffer(Jimp.MIME_PNG, (err, buff) => { if (err) return message.say('An Unknown Error Occurred.'); diff --git a/commands/avataredit/triggered.js b/commands/avataredit/triggered.js index 52e4b191..02600a4c 100644 --- a/commands/avataredit/triggered.js +++ b/commands/avataredit/triggered.js @@ -21,10 +21,10 @@ module.exports = class TriggeredCommand extends Command { if (!message.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) return message.say('This Command requires the `Attach Files` Permission.'); const { user } = args; - const userAvatar = user.displayAvatarURL.replace(/(png|jpg|jpeg|gif|webp)/, 'png'); + const avatarURL = user.displayAvatarURL.replace(/(png|jpg|jpeg|gif|webp)/, 'png'); const blank = new Jimp(320, 371, 0xFFFFFFFF); let images = []; - images.push(Jimp.read(userAvatar)); + images.push(Jimp.read(avatarURL)); images.push(Jimp.read('https://i.imgur.com/tF9yF62.png')); const [avatar, triggered] = await Promise.all(images); avatar.resize(320, 320); diff --git a/commands/games/mathgame.js b/commands/games/mathgame.js index ebb1c1d5..10a585b4 100644 --- a/commands/games/mathgame.js +++ b/commands/games/mathgame.js @@ -19,7 +19,7 @@ module.exports = class MathGameCommand extends Command { return true; return 'Please set the difficulty to either `easy`, `medium`, `hard`, `extreme`, or `impossible`.'; }, - parse: text => text.toLowerCase() + parse: difficulty => difficulty.toLowerCase() }] }); } @@ -51,9 +51,9 @@ module.exports = class MathGameCommand extends Command { const value1 = Math.floor(Math.random() * value) + 1; const value2 = Math.floor(Math.random() * value) + 1; const expression = `${value1} ${operation} ${value2}`; - const solved = math.eval(expression); + const solved = math.eval(expression).toString(); const embed = new RichEmbed() - .setTitle('You have **ten** seconds to answer:') + .setTitle('You have **10** seconds to answer:') .setDescription(expression); await message.embed(embed); try { @@ -62,7 +62,7 @@ module.exports = class MathGameCommand extends Command { time: 10000, errors: ['time'] }); - if (collected.first().content !== solved.toString()) + if (collected.first().content !== solved) return message.say(`Aw... Too bad, try again next time!\nThe correct answer is: ${solved}`); return message.say(`Good Job! You won! ${solved} is the correct answer!`); } catch (err) { diff --git a/commands/games/quiz.js b/commands/games/quiz.js index f818f66e..775b6235 100644 --- a/commands/games/quiz.js +++ b/commands/games/quiz.js @@ -22,11 +22,10 @@ module.exports = class QuizCommand extends Command { try { const { body } = await request .get('http://jservice.io/api/random?count=1'); - const data = body[0]; - const answer = data.answer.toLowerCase().replace(/(|<\/i>)/g, ''); + const answer = body[0].answer.toLowerCase().replace(/(|<\/i>)/g, ''); const embed = new RichEmbed() - .setTitle('You have **fifteen** seconds to answer this question:') - .setDescription(`**Category: ${data.category.title}**\n${data.question}`); + .setTitle('You have **15** seconds to answer this question:') + .setDescription(`**Category: ${body[0].category.title}**\n${body[0].question}`); await message.embed(embed); try { const collected = await message.channel.awaitMessages(res => res.author.id === message.author.id, { @@ -41,7 +40,7 @@ module.exports = class QuizCommand extends Command { return message.say(`Aw... Too bad, try again next time!\nThe Correct Answer was: ${answer}`); } } catch (err) { - return message.say(':x: Error! Something went wrong!'); + return message.say('An Unknown Error Occurred.'); } } }; diff --git a/commands/games/rockpaperscissors.js b/commands/games/rockpaperscissors.js index 457f1b1f..4b0d5585 100644 --- a/commands/games/rockpaperscissors.js +++ b/commands/games/rockpaperscissors.js @@ -15,12 +15,12 @@ module.exports = class RockPaperScissorsCommand extends Command { key: 'choice', prompt: '`Rock`, `Paper`, or `Scissors`?', type: 'string', - validate: rps => { - if (['rock', 'paper', 'scissors'].includes(rps.toLowerCase())) + validate: choice => { + if (['rock', 'paper', 'scissors'].includes(choice.toLowerCase())) return true; return 'Please enter either `rock`, `paper`, or `scissors`.'; }, - parse: text => text.toLowerCase() + parse: choice => choice.toLowerCase() }] }); } diff --git a/commands/games/typinggame.js b/commands/games/typinggame.js index 70844fc2..46a2026c 100644 --- a/commands/games/typinggame.js +++ b/commands/games/typinggame.js @@ -18,7 +18,7 @@ module.exports = class TypingGameCommand extends Command { return true; return 'Please set the difficulty to either `easy`, `medium`, `hard`, `extreme`, or `impossible`.'; }, - parse: text => text.toLowerCase() + parse: difficulty => difficulty.toLowerCase() }] }); } @@ -30,31 +30,25 @@ module.exports = class TypingGameCommand extends Command { const { difficulty } = args; const sentence = sentences[Math.floor(Math.random() * sentences.length)]; let time; - let levelWord; switch (difficulty) { case 'easy': time = 25000; - levelWord = 'twenty-five'; break; case 'medium': time = 20000; - levelWord = 'twenty'; break; case 'hard': time = 15000; - levelWord = 'fifteen'; break; case 'extreme': time = 10000; - levelWord = 'ten'; break; case 'impossible': time = 5000; - levelWord = 'five'; break; } const embed = new RichEmbed() - .setTitle(`You have **${levelWord}** seconds to type:`) + .setTitle(`You have **${time / 1000}** seconds to type:`) .setDescription(sentence); await message.embed(embed); try { diff --git a/commands/imageedit/meme.js b/commands/imageedit/meme.js index 8767ba2e..9ddfa199 100644 --- a/commands/imageedit/meme.js +++ b/commands/imageedit/meme.js @@ -1,5 +1,5 @@ const { Command } = require('discord.js-commando'); -const memecodes = require('./memecodes'); +const codes = require('./memecodes'); module.exports = class MemeCommand extends Command { constructor(client) { @@ -8,37 +8,37 @@ module.exports = class MemeCommand extends Command { group: 'imageedit', memberName: 'meme', description: 'Sends a Meme with text of your choice, and a background of your choice.', - details: `**Codes:** ${memecodes.join(', ')}`, + details: `**Codes:** ${codes.join(', ')}`, args: [{ key: 'type', prompt: 'What meme type do you want to use?', type: 'string', validate: type => { - if (memecodes.includes(type.toLowerCase())) + if (codes.includes(type.toLowerCase())) return true; return `${type.toLowerCase()} is not a valid meme type. Use \`x;help meme\` to view a list of types.`; }, - parse: text => text.toLowerCase() + parse: type => type.toLowerCase() }, { - key: 'toprow', + key: 'top', prompt: 'What should the top row of the meme to be?', type: 'string', - validate: toprow => { - if (/[a-zA-Z0-9.,!?'\s]+$/g.test(toprow) && toprow.length < 100) + validate: top => { + if (/[a-zA-Z0-9.,!?'\s]+$/g.test(top) && top.length < 100) return true; - return `Please do not use special characters and keep the rows under 100 characters each, top row has ${toprow.length}.`; + return `Please do not use special characters and keep the rows under 100 characters each, top row has ${top.length}.`; }, - parse: text => text.replace(/[ ]/g, '-').replace(/[?]/g, '~q') + parse: top => top.replace(/[ ]/g, '-').replace(/[?]/g, '~q') }, { - key: 'bottomrow', + key: 'bottom', prompt: 'What should the bottom row of the meme to be?', type: 'string', - validate: bottomrow => { - if (/[a-zA-Z0-9.,!?'\s]+$/g.test(bottomrow) && bottomrow.length < 100) + validate: bottom => { + if (/[a-zA-Z0-9.,!?'\s]+$/g.test(bottom) && bottom.length < 100) return true; - return `Please do not use special characters and keep the rows under 100 characters each, bottom row has ${bottomrow.length}.`; + return `Please do not use special characters and keep the rows under 100 characters each, bottom row has ${bottom.length}.`; }, - parse: text => text.replace(/[ ]/g, '-').replace(/[?]/g, '~q') + parse: bottom => bottom.replace(/[ ]/g, '-').replace(/[?]/g, '~q') }] }); } @@ -47,8 +47,8 @@ module.exports = class MemeCommand extends Command { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) 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`]}) + const { type, top, bottom } = args; + return message.channel.send({files: [`https://memegen.link/${type}/${top}/${bottom}.jpg`]}) .catch(() => message.say('An Unknown Error Occurred.')); } }; diff --git a/commands/moderation/ban.js b/commands/moderation/ban.js index 4c86990d..7b423634 100644 --- a/commands/moderation/ban.js +++ b/commands/moderation/ban.js @@ -54,7 +54,7 @@ module.exports = class BanCommand extends Command { await member.ban(7); await message.say(':ok_hand:'); const embed = new RichEmbed() - .setAuthor(message.author.tag, message.author.avatarURL) + .setAuthor(message.author.tag, message.author.displayAvatarURL) .setColor(0xFF0000) .setTimestamp() .setDescription(`**Member:** ${member.user.tag} (${member.id})\n**Action:** Ban\n**Reason:** ${reason}`); diff --git a/commands/moderation/kick.js b/commands/moderation/kick.js index 7bbcb583..5662e6f1 100644 --- a/commands/moderation/kick.js +++ b/commands/moderation/kick.js @@ -51,7 +51,7 @@ module.exports = class KickCommand extends Command { await member.kick(); await message.say(':ok_hand:'); const embed = new RichEmbed() - .setAuthor(message.author.tag, message.author.avatarURL) + .setAuthor(message.author.tag, message.author.displayAvatarURL) .setColor(0xFFA500) .setTimestamp() .setDescription(`**Member:** ${member.user.tag} (${member.id})\n**Action:** Kick\n**Reason:** ${reason}`); diff --git a/commands/moderation/lockdown.js b/commands/moderation/lockdown.js index 892123ad..8cf7d079 100644 --- a/commands/moderation/lockdown.js +++ b/commands/moderation/lockdown.js @@ -17,7 +17,7 @@ module.exports = class LockdownCommand extends Command { return true; return 'Please enter either `start` or `stop`.'; }, - parse: text => text.toLowerCase() + parse: type => type.toLowerCase() }] }); } diff --git a/commands/moderation/prune.js b/commands/moderation/prune.js index c78345a8..c4284887 100644 --- a/commands/moderation/prune.js +++ b/commands/moderation/prune.js @@ -34,11 +34,10 @@ module.exports = class PruneCommand extends Command { return message.say('This Command requires the `Read Message History` Permission.'); if (!message.channel.permissionsFor(this.client.user).has('MANAGE_MESSAGES')) return message.say('This Command requires the `Manage Messages` Permission.'); - let { count } = args; - count = count + 1; + const { count } = args; try { const messages = await message.channel.fetchMessages({ - limit: count + limit: count + 1 }); await message.channel.bulkDelete(messages, true); return null; diff --git a/commands/moderation/unban.js b/commands/moderation/unban.js index 6ad7a4a5..55474e5f 100644 --- a/commands/moderation/unban.js +++ b/commands/moderation/unban.js @@ -13,13 +13,13 @@ module.exports = class UnbanCommand extends Command { description: 'Unbans a user and logs the unban to the mod_logs.', guildOnly: true, args: [{ - key: 'memberID', + key: 'id', prompt: 'What member do you want to unban? Please enter the ID of the user.', type: 'string', - validate: userID => { - if (userID.length === 18) + validate: id => { + if (id.length === 18) return true; - return `${userID} is not a valid ID. Please enter the user you wish to unban's ID.`; + return `${id} is not a valid ID. Please enter the user you wish to unban's ID.`; } }, { key: 'reason', @@ -46,19 +46,19 @@ module.exports = class UnbanCommand extends Command { return message.say('This Command requires a channel named `mod_logs` or one custom set with the `modchannel` command.'); if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) return message.say('This Command requires the `Embed Links` Permission.'); - const { memberID, reason } = args; + const { id, reason } = args; const bans = await message.guild.fetchBans(); - if (!bans.has(memberID)) + if (!bans.has(id)) return message.say('This ID is not in the Guild Banlist.'); - const unbanUser = await bans.get(memberID); + const member = await bans.get(id); try { - await message.guild.unban(unbanUser); + await message.guild.unban(member); await message.say(':ok_hand:'); const embed = new RichEmbed() - .setAuthor(message.author.tag, message.author.avatarURL) + .setAuthor(message.author.tag, message.author.displayAvatarURL) .setColor(0x00AE86) .setTimestamp() - .setDescription(`**Member:** ${unbanUser.tag} (${unbanUser.id})\n**Action:** Unban\n**Reason:** ${reason}`); + .setDescription(`**Member:** ${member.tag} (${member.id})\n**Action:** Unban\n**Reason:** ${reason}`); return modlogs.send({embed}); } catch (err) { return message.say('An Unknown Error Occurred.'); diff --git a/commands/moderation/warn.js b/commands/moderation/warn.js index 67216fa9..4a344c97 100644 --- a/commands/moderation/warn.js +++ b/commands/moderation/warn.js @@ -40,7 +40,7 @@ module.exports = class WarnCommand extends Command { try { await message.say(':ok_hand:'); const embed = new RichEmbed() - .setAuthor(message.author.tag, message.author.avatarURL) + .setAuthor(message.author.tag, message.author.displayAvatarURL) .setColor(0xFFFF00) .setTimestamp() .setDescription(`**Member:** ${member.user.tag} (${member.id})\n**Action:** Warn\n**Reason:** ${reason}`); diff --git a/commands/random/canyounot.js b/commands/random/canyounot.js deleted file mode 100644 index e918f4eb..00000000 --- a/commands/random/canyounot.js +++ /dev/null @@ -1,16 +0,0 @@ -const { Command } = require('discord.js-commando'); - -module.exports = class CanYouNotCommand extends Command { - constructor(client) { - super(client, { - name: 'canyounot', - group: 'random', - memberName: 'canyounot', - description: 'Can YOU not?' - }); - } - - run(message) { - return message.say('Can YOU not?'); - } -}; diff --git a/commands/random/easteregg.js b/commands/random/easteregg.js index d62bb8af..63eb2498 100644 --- a/commands/random/easteregg.js +++ b/commands/random/easteregg.js @@ -20,7 +20,7 @@ module.exports = class EasterEggCommand extends Command { return true; return 'Nope, that\'s not a valid easter egg. Try again!'; }, - parse: text => text.toLowerCase() + parse: tag => tag.toLowerCase() }] }); } diff --git a/commands/random/eastereggs.json b/commands/random/eastereggs.json index 4d8c1b99..1cac64d0 100644 --- a/commands/random/eastereggs.json +++ b/commands/random/eastereggs.json @@ -21,5 +21,8 @@ "egg": "You're an egg.", "beta": "https://cdn.discordapp.com/attachments/252317073814978561/304812045851688963/image.jpg", "pathetic": "https://cdn.discordapp.com/attachments/252317073814978561/304812045851688963/image.jpg", - "swagolor": "https://cdn.discordapp.com/attachments/252317073814978561/306110096491151363/Swagolor.png" + "swagolor": "https://cdn.discordapp.com/attachments/252317073814978561/306110096491151363/Swagolor.png", + "canyounot": "Can YOU not?", + "slowclap": "*slow clap*", + "justdoit": "https://www.youtube.com/watch?v=ZXsQAXx_ao0" } diff --git a/commands/random/motivate.js b/commands/random/motivate.js deleted file mode 100644 index 47401816..00000000 --- a/commands/random/motivate.js +++ /dev/null @@ -1,22 +0,0 @@ -const { Command } = require('discord.js-commando'); - -module.exports = class MotivateCommand extends Command { - constructor(client) { - super(client, { - name: 'motivate', - group: 'random', - memberName: 'motivate', - description: 'Motivates something/someone.', - args: [{ - key: 'thing', - prompt: 'What do you want to motivate?', - type: 'string' - }] - }); - } - - run(message, args) { - const { thing } = args; - return message.say(`${thing}, https://www.youtube.com/watch?v=ZXsQAXx_ao0`); - } -}; diff --git a/commands/random/nitro.js b/commands/random/nitro.js index 8dd12e23..0fb17cc5 100644 --- a/commands/random/nitro.js +++ b/commands/random/nitro.js @@ -20,7 +20,7 @@ module.exports = class NitroCommand extends Command { .setThumbnail('https://pbs.twimg.com/profile_images/814184180649197568/y2eZcVMq.jpg') .setColor(0x748BD9) .setURL('https://discordapp.com/nitro') - .setDescription('This Message can only be viewed by members with Discord Nitro.\n\n\n[More Information](https://discordapp.com/nitro)'); + .setDescription('This Message can only be viewed by members with Discord Nitro.\n[More Information](https://discordapp.com/nitro)'); return message.embed(embed); } }; diff --git a/commands/random/slowclap.js b/commands/random/slowclap.js deleted file mode 100644 index ad257685..00000000 --- a/commands/random/slowclap.js +++ /dev/null @@ -1,16 +0,0 @@ -const { Command } = require('discord.js-commando'); - -module.exports = class SlowClapCommand extends Command { - constructor(client) { - super(client, { - name: 'slowclap', - group: 'random', - memberName: 'slowclap', - description: '*Slow Clap*.' - }); - } - - run(message) { - return message.say('*slow clap*'); - } -}; diff --git a/commands/random/today.js b/commands/random/today.js index f81fbbf0..cd7b1ce8 100644 --- a/commands/random/today.js +++ b/commands/random/today.js @@ -20,15 +20,15 @@ module.exports = class TodayCommand extends Command { const { text } = await request .get('http://history.muffinlabs.com/date') .buffer(true); - const data = JSON.parse(text); - const events = data.data.Events; - const randomNumber = Math.floor(Math.random() * events.length); + const parsed = JSON.parse(text); + const events = parsed.data.Events; + const random = Math.floor(Math.random() * events.length); const embed = new RichEmbed() .setColor(0x9797FF) - .setURL(data.url) - .setTitle(`On this day (${data.date})...`) + .setURL(parsed.url) + .setTitle(`On this day (${parsed.date})...`) .setTimestamp() - .setDescription(`${events[randomNumber].text} (${events[randomNumber].year})`); + .setDescription(`${events[random].year}: ${events[random].text}`); return message.embed(embed); } catch (err) { return message.say('An Unknown Error Occurred.'); diff --git a/commands/response/coin.js b/commands/response/coin.js index 8d2088e4..2e60a2a8 100644 --- a/commands/response/coin.js +++ b/commands/response/coin.js @@ -16,7 +16,7 @@ module.exports = class CoinFlipCommand extends Command { } run(message) { - const coin = sides[Math.floor(Math.random() * sides.length)]; - return message.say(`It landed on ${coin}!`); + const side = sides[Math.floor(Math.random() * sides.length)]; + return message.say(`It landed on ${side}!`); } }; diff --git a/commands/response/name.js b/commands/response/name.js index e052ca66..db79065f 100644 --- a/commands/response/name.js +++ b/commands/response/name.js @@ -17,7 +17,7 @@ module.exports = class RandomNameCommand extends Command { return true; return 'Please enter either `male` or `female`.'; }, - parse: text => text.toLowerCase() + parse: gender => gender.toLowerCase() }] }); } diff --git a/commands/response/quantumcoin.js b/commands/response/quantumcoin.js index ffaa0aa2..aedad07f 100644 --- a/commands/response/quantumcoin.js +++ b/commands/response/quantumcoin.js @@ -15,7 +15,7 @@ module.exports = class QuantumCoinCommand extends Command { } run(message) { - const qcoin = sides[Math.floor(Math.random() * sides.length)]; - return message.say(`It landed ${qcoin}.`); + const side = sides[Math.floor(Math.random() * sides.length)]; + return message.say(`It landed ${side}.`); } }; diff --git a/commands/response/ship.js b/commands/response/ship.js index a274182a..f52586af 100644 --- a/commands/response/ship.js +++ b/commands/response/ship.js @@ -20,7 +20,7 @@ module.exports = class ShipCommand extends Command { run(message, args) { const { things } = args; - const percentage = Math.floor(Math.random() * 100) + 1; - return message.say(`I'd give ${things} a ${percentage}%!`); + const rating = Math.floor(Math.random() * 100) + 1; + return message.say(`I'd give ${things} a ${rating}%!`); } }; diff --git a/commands/search/botinfo.js b/commands/search/botinfo.js index 8d43bcac..57759d9a 100644 --- a/commands/search/botinfo.js +++ b/commands/search/botinfo.js @@ -21,11 +21,10 @@ module.exports = class BotSearchCommand extends Command { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return message.say('This Command requires the `Embed Links` Permission.'); - let { bot } = args; - bot = bot.id; + const { bot } = args; try { const { body } = await request - .get(`https://bots.discord.pw/api/bots/${bot}`) + .get(`https://bots.discord.pw/api/bots/${bot.id}`) .set({ 'Authorization': process.env.DISCORD_BOTS_KEY }); diff --git a/commands/search/define.js b/commands/search/define.js index 94786fb3..d83caf2c 100644 --- a/commands/search/define.js +++ b/commands/search/define.js @@ -10,10 +10,10 @@ module.exports = class DefineCommand extends Command { memberName: 'define', description: 'Defines a word.', args: [{ - key: 'word', + key: 'query', prompt: 'What would you like to define?', type: 'string', - parse: text => encodeURIComponent(text) + parse: query => encodeURIComponent(query) }] }); } @@ -22,15 +22,14 @@ module.exports = class DefineCommand extends Command { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return message.say('This Command requires the `Embed Links` Permission.'); - const { word } = args; + const { query } = args; try { const { body } = 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}`); - const data = body[0]; + .get(`http://api.wordnik.com:80/v4/word.json/${query}/definitions?limit=1&includeRelated=false&useCanonical=false&api_key=${process.env.WORDNIK_KEY}`); const embed = new RichEmbed() .setColor(0x9797FF) - .setTitle(data.word) - .setDescription(data.text); + .setTitle(body[0].word) + .setDescription(body[0].text); return message.embed(embed); } catch (err) { return message.say('An Error Occurred. The word may not have been found.'); diff --git a/commands/search/forecast.js b/commands/search/forecast.js index 46fc4a95..91a79326 100644 --- a/commands/search/forecast.js +++ b/commands/search/forecast.js @@ -10,7 +10,7 @@ module.exports = class ForecastCommand extends Command { memberName: 'forecast', description: 'Gets the seven-day forecast for a specified location.', args: [{ - key: 'location', + key: 'query', prompt: 'What location would you like to get the forecast for?', type: 'string' }] @@ -21,31 +21,30 @@ module.exports = class ForecastCommand extends Command { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return message.say('This Command requires the `Embed Links` Permission.'); - const { location } = args; + const { query } = args; try { const { body } = await request - .get(`https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where u=\'f\' AND woeid in (select woeid from geo.places(1) where text="${location}")&format=json`); - const info = body.query.results.channel; - const data = info.item.forecast; + .get(`https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where u=\'f\' AND woeid in (select woeid from geo.places(1) where text="${query}")&format=json`); + const forecasts = body.query.results.channel.item.forecast; const embed = new RichEmbed() .setColor(0x0000FF) - .setAuthor(info.title, 'http://media.idownloadblog.com/wp-content/uploads/2013/12/yahoo-weather-213x220.png') - .setURL(info.link) + .setAuthor(body.query.results.channel.title, 'http://media.idownloadblog.com/wp-content/uploads/2013/12/yahoo-weather-213x220.png') + .setURL(body.query.results.channel.link) .setTimestamp() - .addField(`**${data[0].day} - ${data[0].date}:**`, - `**High:** ${data[0].high}°F, **Low:** ${data[0].low}°F, **Condition:** ${data[0].text}`) - .addField(`**${data[1].day} - ${data[1].date}:**`, - `**High:** ${data[1].high}°F, **Low:** ${data[1].low}°F, **Condition:** ${data[1].text}`) - .addField(`**${data[2].day} - ${data[2].date}:**`, - `**High:** ${data[2].high}°F, **Low:** ${data[2].low}°F, **Condition:** ${data[2].text}`) - .addField(`**${data[3].day} - ${data[3].date}:**`, - `**High:** ${data[3].high}°F, **Low:** ${data[3].low}°F, **Condition:** ${data[3].text}`) - .addField(`**${data[4].day} - ${data[4].date}:**`, - `**High:** ${data[4].high}°F, **Low:** ${data[4].low}°F, **Condition:** ${data[4].text}`) - .addField(`**${data[5].day} - ${data[5].date}:**`, - `**High:** ${data[5].high}°F, **Low:** ${data[5].low}°F, **Condition:** ${data[5].text}`) - .addField(`**${data[6].day} - ${data[6].date}:**`, - `**High:** ${data[6].high}°F, **Low:** ${data[6].low}°F, **Condition:** ${data[6].text}`); + .addField(`**${forecasts[0].day} - ${forecasts[0].date}:**`, + `**High:** ${forecasts[0].high}°F, **Low:** ${forecasts[0].low}°F, **Condition:** ${forecasts[0].text}`) + .addField(`**${forecasts[1].day} - ${forecasts[1].date}:**`, + `**High:** ${forecasts[1].high}°F, **Low:** ${forecasts[1].low}°F, **Condition:** ${forecasts[1].text}`) + .addField(`**${forecasts[2].day} - ${forecasts[2].date}:**`, + `**High:** ${forecasts[2].high}°F, **Low:** ${forecasts[2].low}°F, **Condition:** ${forecasts[2].text}`) + .addField(`**${forecasts[3].day} - ${forecasts[3].date}:**`, + `**High:** ${forecasts[3].high}°F, **Low:** ${forecasts[3].low}°F, **Condition:** ${forecasts[3].text}`) + .addField(`**${forecasts[4].day} - ${forecasts[4].date}:**`, + `**High:** ${forecasts[4].high}°F, **Low:** ${forecasts[4].low}°F, **Condition:** ${forecasts[4].text}`) + .addField(`**${forecasts[5].day} - ${forecasts[5].date}:**`, + `**High:** ${forecasts[5].high}°F, **Low:** ${forecasts[5].low}°F, **Condition:** ${forecasts[5].text}`) + .addField(`**${forecasts[6].day} - ${forecasts[6].date}:**`, + `**High:** ${forecasts[6].high}°F, **Low:** ${forecasts[6].low}°F, **Condition:** ${forecasts[6].text}`); return message.embed(embed); } catch (err) { 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 2a03c633..8d45aa29 100644 --- a/commands/search/google.js +++ b/commands/search/google.js @@ -14,7 +14,7 @@ module.exports = class GoogleCommand extends Command { key: 'query', prompt: 'What would you like to search for?', type: 'string', - parse: text => encodeURIComponent(text) + parse: query => encodeURIComponent(query) }] }); } diff --git a/commands/search/imdb.js b/commands/search/imdb.js index 864518f7..031547cf 100644 --- a/commands/search/imdb.js +++ b/commands/search/imdb.js @@ -10,10 +10,10 @@ module.exports = class IMDBCommand extends Command { memberName: 'imdb', description: 'Searches IMDB for a specified movie.', args: [{ - key: 'movie', + key: 'query', prompt: 'What movie or TV Show would you like to search for?', type: 'string', - parse: text => encodeURIComponent(text) + parse: query => encodeURIComponent(query) }] }); } @@ -22,10 +22,10 @@ module.exports = class IMDBCommand extends Command { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return message.say('This Command requires the `Embed Links` Permission.'); - const { movie } = args; + const { query } = args; try { const { body } = await request - .get(`http://www.omdbapi.com/?t=${movie}&plot=full`); + .get(`http://www.omdbapi.com/?t=${query}&plot=full`); const embed = new RichEmbed() .setColor(0xDBA628) .setAuthor('IMDB', 'http://static.wixstatic.com/media/c65cbf_31901b544fe24f1890134553bf40c8be.png') diff --git a/commands/search/lmgtfy.js b/commands/search/lmgtfy.js index 95aa5c96..0a851e85 100644 --- a/commands/search/lmgtfy.js +++ b/commands/search/lmgtfy.js @@ -11,7 +11,7 @@ module.exports = class LMGTFYCommand extends Command { key: 'query', prompt: 'What would you like to the link to search for?', type: 'string', - parse: text => encodeURIComponent(text) + parse: query => encodeURIComponent(query) }] }); } diff --git a/commands/search/map.js b/commands/search/map.js index a387c39c..f9ae36e7 100644 --- a/commands/search/map.js +++ b/commands/search/map.js @@ -18,10 +18,10 @@ module.exports = class MapCommand extends Command { return 'Please enter a zoom value from 1-20'; } }, { - key: 'location', + key: 'query', prompt: 'What location you like to get a map image for?', type: 'string', - parse: text => encodeURIComponent(text) + parse: query => encodeURIComponent(query) }] }); } @@ -30,10 +30,10 @@ module.exports = class MapCommand extends Command { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) return message.say('This Command requires the `Attach Files` Permission.'); - const { zoom, location } = args; + const { zoom, query } = 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}`); + .get(`https://maps.googleapis.com/maps/api/staticmap?center=${query}&zoom=${zoom}&size=500x500&key=${process.env.GOOGLE_KEY}`); return message.channel.send({files: [{attachment: body}]}); } catch (err) { 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 05a7c880..1a3d898e 100644 --- a/commands/search/neopet.js +++ b/commands/search/neopet.js @@ -10,19 +10,19 @@ module.exports = class NeopetCommand extends Command { memberName: 'neopet', description: 'Gives a Neopet\'s image, searchable by name.', args: [{ - key: 'pet', + key: 'query', prompt: 'What pet would you like to get the image of?', type: 'string', - parse: text => encodeURIComponent(text) + parse: query => encodeURIComponent(query) }] }); } async run(message, args) { - const { pet } = args; + const { query } = args; try { const { text } = await request - .get(`http://www.sunnyneo.com/petimagefinder.php?name=${pet}&size=5&mood=1`); + .get(`http://www.sunnyneo.com/petimagefinder.php?name=${query}&size=5&mood=1`); const $ = cheerio.load(text); const link = $('textarea').first().text(); if (!link.includes('cp')) diff --git a/commands/search/osu.js b/commands/search/osu.js index 4ac58f9b..c3737233 100644 --- a/commands/search/osu.js +++ b/commands/search/osu.js @@ -10,10 +10,10 @@ module.exports = class OsuCommand extends Command { memberName: 'osu', description: 'Searches Osu! user data.', args: [{ - key: 'username', + key: 'query', prompt: 'What osu username would you like to search for?', type: 'string', - parse: text => encodeURIComponent(text) + parse: query => encodeURIComponent(query) }] }); } @@ -22,39 +22,38 @@ module.exports = class OsuCommand extends Command { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return message.say('This Command requires the `Embed Links` Permission.'); - const { username } = args; + const { query } = args; try { const { body } = await request - .get(`https://osu.ppy.sh/api/get_user?k=${process.env.OSU_KEY}&u=${username}&type=string`); - const data = body[0]; + .get(`https://osu.ppy.sh/api/get_user?k=${process.env.OSU_KEY}&u=${query}&type=string`); const embed = new RichEmbed() .setColor(0xFF66AA) .setAuthor('osu!', 'http://vignette3.wikia.nocookie.net/osugame/images/c/c9/Logo.png/revision/latest?cb=20151219073209') .setURL('https://osu.ppy.sh/') .addField('**Username:**', - data.username, true) + body[0].username, true) .addField('**ID:**', - data.user_id, true) + body[0].user_id, true) .addField('**Level:**', - data.level, true) + body[0].level, true) .addField('**Accuracy**', - data.accuracy, true) + body[0].accuracy, true) .addField('**Rank:**', - data.pp_rank, true) + body[0].pp_rank, true) .addField('**Play Count:**', - data.playcount, true) + body[0].playcount, true) .addField('**Country:**', - data.country, true) + body[0].country, true) .addField('**Ranked Score:**', - data.ranked_score, true) + body[0].ranked_score, true) .addField('**Total Score:**', - data.total_score, true) + body[0].total_score, true) .addField('**SS:**', - data.count_rank_ss, true) + body[0].count_rank_ss, true) .addField('**S:**', - data.count_rank_s, true) + body[0].count_rank_s, true) .addField('**A:**', - data.count_rank_a, true); + body[0].count_rank_a, true); return message.embed(embed); } catch (err) { 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 85bae835..68879e88 100644 --- a/commands/search/soundcloud.js +++ b/commands/search/soundcloud.js @@ -26,22 +26,21 @@ module.exports = class SoundCloudCommand extends Command { try { const { body } = await request .get(`https://api.soundcloud.com/tracks?q=${query}&client_id=${process.env.SOUNDCLOUD_KEY}`); - const data = body[0]; const embed = new RichEmbed() .setColor(0xF15A22) - .setAuthor(data.title, 'http://icons.iconarchive.com/icons/danleech/simple/1024/soundcloud-icon.png') - .setURL(data.permalink_url) - .setThumbnail(data.artwork_url) + .setAuthor(body[0].title, 'http://icons.iconarchive.com/icons/danleech/simple/1024/soundcloud-icon.png') + .setURL(body[0].permalink_url) + .setThumbnail(body[0].artwork_url) .addField('**Artist:**', - data.user.username) + body[0].user.username) .addField('**Download Count:**', - data.download_count, true) + body[0].download_count, true) .addField('**Comment Count**', - data.comment_count, true) + body[0].comment_count, true) .addField('**Playback Count:**', - data.playback_count, true) + body[0].playback_count, true) .addField('**Favorited Count:**', - data.favoritings_count, true); + body[0].favoritings_count, true); return message.embed(embed); } catch (err) { 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 c6b38b7a..4dc71549 100644 --- a/commands/search/urban.js +++ b/commands/search/urban.js @@ -10,7 +10,7 @@ module.exports = class UrbanCommand extends Command { memberName: 'urban', description: 'Searches Urban Dictionary for a word.', args: [{ - key: 'word', + key: 'query', prompt: 'What would you like to define?', type: 'string', parse: text => encodeURIComponent(text) @@ -22,19 +22,18 @@ module.exports = class UrbanCommand extends Command { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return message.say('This Command requires the `Embed Links` Permission.'); - const { word } = args; + const { query } = args; try { const { body } = await request - .get(`http://api.urbandictionary.com/v0/define?term=${word}`); - const data = body.list[0]; + .get(`http://api.urbandictionary.com/v0/define?term=${query}`); const embed = new RichEmbed() .setColor(0x32a8f0) .setAuthor('Urban Dictionary', 'http://a1.mzstatic.com/eu/r30/Purple71/v4/66/54/68/6654683f-cacd-4a55-1784-f14257f77874/icon175x175.png') - .setURL(data.permalink) - .setTitle(data.word) - .setDescription(data.definition.substr(0, 2000)) + .setURL(body.list[0].permalink) + .setTitle(body.list[0].word) + .setDescription(body.list[0].definition.substr(0, 2000)) .addField('**Example:**', - data.example.substr(0, 2000) || 'None'); + body.list[0].example.substr(0, 2000) || 'None'); return message.embed(embed); } catch (err) { 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 f07997ff..40aa5ac8 100644 --- a/commands/search/wattpad.js +++ b/commands/search/wattpad.js @@ -10,7 +10,7 @@ module.exports = class WattpadCommand extends Command { memberName: 'wattpad', description: 'Searches Wattpad for a book.', args: [{ - key: 'book', + key: 'query', prompt: 'What book would you like to search for?', type: 'string', parse: text => encodeURIComponent(text) @@ -22,32 +22,31 @@ module.exports = class WattpadCommand extends Command { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return message.say('This Command requires the `Embed Links` Permission.'); - const { book } = args; + const { query } = args; try { const { body } = await request - .get(`https://api.wattpad.com:443/v4/stories?query=${book}&limit=1`) + .get(`https://api.wattpad.com:443/v4/stories?query=${query}&limit=1`) .set({ 'Authorization': `Basic ${process.env.WATTPAD_KEY}` }); - const data = body.stories[0]; const embed = new RichEmbed() .setColor(0xF89C34) .setAuthor('Wattpad', 'http://www.selfpubtoolbox.com/wp-content/uploads/2015/05/a6044fd3a88acd5043860484db972ca6.png') - .setURL(data.url) - .setTitle(data.title) - .setDescription(data.description.substr(0, 2000)) + .setURL(body.stories[0].url) + .setTitle(body.stories[0].title) + .setDescription(body.stories[0].description.substr(0, 2000)) .addField('**Author:**', - data.user, true) + body.stories[0].user, true) .addField('**Parts:**', - data.numParts, true) + body.stories[0].numParts, true) .addField('**Created On:**', - data.createDate, true) + body.stories[0].createDate, true) .addField('**Votes:**', - data.voteCount, true) + body.stories[0].voteCount, true) .addField('**Reads:**', - data.readCount, true) + body.stories[0].readCount, true) .addField('**Comments:**', - data.commentCount, true); + body.stories[0].commentCount, true); return message.embed(embed); } catch (err) { 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 62ec67c5..1cfa9b0d 100644 --- a/commands/search/weather.js +++ b/commands/search/weather.js @@ -10,7 +10,7 @@ module.exports = class WeatherCommand extends Command { memberName: 'weather', description: 'Gets weather information for a specified location.', args: [{ - key: 'location', + key: 'query', prompt: 'What location would you like to get the current weather for?', type: 'string' }] @@ -21,40 +21,39 @@ module.exports = class WeatherCommand extends Command { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return message.say('This Command requires the `Embed Links` Permission.'); - const { location } = args; + const { query } = args; try { const { body } = await request - .get(`https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where u=\'f\' AND woeid in (select woeid from geo.places(1) where text="${location}")&format=json`); - const data = body.query.results.channel; + .get(`https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where u=\'f\' AND woeid in (select woeid from geo.places(1) where text="${query}")&format=json`); const embed = new RichEmbed() .setColor(0x0000FF) - .setAuthor(data.title, 'http://media.idownloadblog.com/wp-content/uploads/2013/12/yahoo-weather-213x220.png') - .setURL(data.link) + .setAuthor(body.query.results.channel.title, 'http://media.idownloadblog.com/wp-content/uploads/2013/12/yahoo-weather-213x220.png') + .setURL(body.query.results.channel.link) .setTimestamp() .addField('**City:**', - data.location.city, true) + body.query.results.channel.location.city, true) .addField('**Country**', - data.location.country, true) + body.query.results.channel.location.country, true) .addField('**Region:**', - data.location.region, true) + body.query.results.channel.location.region, true) .addField('**Condition:**', - data.item.condition.text, true) + body.query.results.channel.item.condition.text, true) .addField('**Temperature:**', - `${data.item.condition.temp}°F`, true) + `${body.query.results.channel.item.condition.temp}°F`, true) .addField('**Humidity:**', - data.atmosphere.humidity, true) + body.query.results.channel.atmosphere.humidity, true) .addField('**Pressure:**', - data.atmosphere.pressure, true) + body.query.results.channel.atmosphere.pressure, true) .addField('**Rising:**', - data.atmosphere.rising, true) + body.query.results.channel.atmosphere.rising, true) .addField('**Visibility:**', - data.atmosphere.visibility, true) + body.query.results.channel.atmosphere.visibility, true) .addField('**Wind Chill:**', - data.wind.chill, true) + body.query.results.channel.wind.chill, true) .addField('**Wind Direction:**', - data.wind.direction, true) + body.query.results.channel.wind.direction, true) .addField('**Wind Speed:**', - data.wind.speed, true); + body.query.results.channel.wind.speed, true); return message.embed(embed); } catch (err) { 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 5678f976..c8309140 100644 --- a/commands/search/wikipedia.js +++ b/commands/search/wikipedia.js @@ -26,14 +26,12 @@ module.exports = class WikipediaCommand extends Command { try { const { body } = await request .get(`https://en.wikipedia.org/w/api.php?action=query&prop=extracts&format=json&titles=${query}&exintro=&explaintext=&redirects=&formatversion=2`); - const data = body.query.pages[0]; - const description = data.extract.substr(0, 2000).split('\n').join('\n\n'); const embed = new RichEmbed() .setColor(0xE7E7E7) - .setTitle(data.title) + .setTitle(body.query.pages[0].title) .setURL(`https://en.wikipedia.org/wiki/${query}`) .setAuthor('Wikipedia', 'https://upload.wikimedia.org/wikipedia/en/thumb/8/80/Wikipedia-logo-v2.svg/1122px-Wikipedia-logo-v2.svg.png') - .setDescription(description); + .setDescription(body.query.pages[0].extract.substr(0, 2000).split('\n').join('\n\n')); return message.embed(embed); } catch (err) { 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 1f152ca1..b7a18686 100644 --- a/commands/search/youtube.js +++ b/commands/search/youtube.js @@ -10,7 +10,7 @@ module.exports = class YouTubeCommand extends Command { memberName: 'youtube', description: 'Searches YouTube for a video.', args: [{ - key: 'video', + key: 'query', prompt: 'What would you like to search for?', type: 'string', parse: text => encodeURIComponent(text) @@ -22,18 +22,17 @@ module.exports = class YouTubeCommand extends Command { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return message.say('This Command requires the `Embed Links` Permission.'); - const { video } = args; + const { query } = args; try { const { body } = await request - .get(`https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&maxResults=1&q=${video}&key=${process.env.GOOGLE_KEY}`); - const data = body.items[0]; + .get(`https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&maxResults=1&q=${query}&key=${process.env.GOOGLE_KEY}`); const embed = new RichEmbed() .setColor(0xDD2825) - .setTitle(data.snippet.title) - .setDescription(data.snippet.description) - .setAuthor(`YouTube - ${data.snippet.channelTitle}`, 'https://cdn3.iconfinder.com/data/icons/social-icons-5/607/YouTube_Play.png') - .setURL(`https://www.youtube.com/watch?v=${data.id.videoId}`) - .setThumbnail(data.snippet.thumbnails.default.url); + .setTitle(body.items[0].snippet.title) + .setDescription(body.items[0].snippet.description) + .setAuthor(`YouTube - ${body.items[0].snippet.channelTitle}`, 'https://cdn3.iconfinder.com/data/icons/social-icons-5/607/YouTube_Play.png') + .setURL(`https://www.youtube.com/watch?v=${body.items[0].id.videoId}`) + .setThumbnail(body.items[0].snippet.thumbnails.default.url); return message.embed(embed); } catch (err) { 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 4c6a8e3b..fb060cc6 100644 --- a/commands/search/yugioh.js +++ b/commands/search/yugioh.js @@ -10,7 +10,7 @@ module.exports = class YuGiOhCommand extends Command { memberName: 'yugioh', description: 'Gets info on a Yu-Gi-Oh! Card.', args: [{ - key: 'card', + key: 'query', prompt: 'What card would you like to get data for?', type: 'string', parse: text => encodeURIComponent(text) @@ -22,38 +22,37 @@ module.exports = class YuGiOhCommand extends Command { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return message.say('This Command requires the `Embed Links` Permission.'); - const { card } = args; + const { query } = args; try { const { body } = await request - .get(`http://yugiohprices.com/api/card_data/${card}`); - const data = body.data; - if (data.card_type === 'monster') { + .get(`http://yugiohprices.com/api/card_data/${query}`); + if (body.data.card_type === 'monster') { const embed = new RichEmbed() .setColor(0xBE5F1F) - .setTitle(data.name) - .setDescription(data.text) + .setTitle(body.data.name) + .setDescription(body.data.text) .setAuthor('Yu-Gi-Oh!', 'http://vignette3.wikia.nocookie.net/yugioh/images/1/10/Back-TF-EN-VG.png/revision/latest?cb=20120824043558') .addField('**Card Type:**', 'Monster', true) .addField('**Type:**', - data.type, true) + body.data.type, true) .addField('**Attribute:**', - data.family, true) + body.data.family, true) .addField('**ATK:**', - data.atk, true) + body.data.atk, true) .addField('**DEF:**', - data.def, true) + body.data.def, true) .addField('**Level:**', - data.level, true); + body.data.level, true); return message.embed(embed); } const embed = new RichEmbed() .setColor(0xBE5F1F) - .setTitle(data.name) - .setDescription(data.text) + .setTitle(body.data.name) + .setDescription(body.data.text) .setAuthor('Yu-Gi-Oh!', 'http://vignette3.wikia.nocookie.net/yugioh/images/1/10/Back-TF-EN-VG.png/revision/latest?cb=20120824043558') .addField('**Card Type:**', - data.card_type, true); + body.data.card_type, true); return message.embed(embed); } catch (err) { return message.say('An Error Occurred. The card may not have been found.'); diff --git a/commands/textedit/binary.js b/commands/textedit/binary.js index f80ac531..271ddd19 100644 --- a/commands/textedit/binary.js +++ b/commands/textedit/binary.js @@ -1,5 +1,5 @@ const { Command } = require('discord.js-commando'); -const stringToBinary = (str) => { +const binary = (str) => { const pad = '00000000'; return unescape(encodeURIComponent(str)) .split('').map(str => { @@ -19,12 +19,12 @@ module.exports = class BinaryCommand extends Command { key: 'text', prompt: 'What text would you like to convert to binary?', type: 'string', - validate: content => { - if (stringToBinary(content).length < 2000) + validate: text => { + if (binary(text).length < 2000) return true; return 'Your message content is too long.'; }, - parse: text => stringToBinary(text) + parse: text => binary(text) }] }); } diff --git a/commands/textedit/embed.js b/commands/textedit/embed.js index c360711a..0ea13257 100644 --- a/commands/textedit/embed.js +++ b/commands/textedit/embed.js @@ -22,7 +22,7 @@ module.exports = class EmbedCommand extends Command { return message.say('This Command requires the `Embed Links` Permission.'); const { text } = args; const embed = new RichEmbed() - .setAuthor(message.author.username, message.author.avatarURL) + .setAuthor(message.author.username, message.author.displayAvatarURL) .setColor(0x00AE86) .setTimestamp() .setDescription(text); diff --git a/commands/textedit/morse.js b/commands/textedit/morse.js index 00c4e5dd..e619cec2 100644 --- a/commands/textedit/morse.js +++ b/commands/textedit/morse.js @@ -13,8 +13,8 @@ module.exports = class MorseCommand extends Command { key: 'text', prompt: 'What text would you like to convert to morse?', type: 'string', - validate: content => { - if (letterTrans(content, dictionary, ' ').length < 1999) + validate: text => { + if (letterTrans(text, dictionary, ' ').length < 1999) return true; return 'Your message content is too long.'; }, diff --git a/commands/textedit/pirate.js b/commands/textedit/pirate.js index 66ca3071..d2cf0bcd 100644 --- a/commands/textedit/pirate.js +++ b/commands/textedit/pirate.js @@ -13,8 +13,8 @@ module.exports = class PirateCommand extends Command { key: 'text', prompt: 'What text would you like to convert to pirate?', type: 'string', - validate: content => { - if (wordTrans(content, dictionary).length < 1999) + validate: text => { + if (wordTrans(text, dictionary).length < 1999) return true; return 'Your message content is too long.'; }, diff --git a/commands/textedit/temmie.js b/commands/textedit/temmie.js index 625a153e..745b55de 100644 --- a/commands/textedit/temmie.js +++ b/commands/textedit/temmie.js @@ -13,8 +13,8 @@ module.exports = class TemmieCommand extends Command { key: 'text', prompt: 'What text would you like to convert to Temmie speak?', type: 'string', - validate: content => { - if (wordTrans(content, dictionary).length < 1999) + validate: text => { + if (wordTrans(text, dictionary).length < 1999) return true; return 'Your message content is too long.'; }, diff --git a/commands/textedit/zalgo.js b/commands/textedit/zalgo.js index 438cf1fe..bf46e671 100644 --- a/commands/textedit/zalgo.js +++ b/commands/textedit/zalgo.js @@ -12,11 +12,11 @@ module.exports = class ZalgoCommand extends Command { key: 'text', prompt: 'What text would you like to convert to zalgo?', type: 'string', - validate: content => { - if (content.length < 500) { + validate: text => { + if (text.length < 500) { return true; } - return `Please keep your text under 500 characters, you have ${content.length}.`; + return `Please keep your text under 500 characters, you have ${text.length}.`; }, parse: text => zalgo(text) }] diff --git a/commands/util/shardinfo.js b/commands/util/shardinfo.js index b91e2199..9eb1d506 100644 --- a/commands/util/shardinfo.js +++ b/commands/util/shardinfo.js @@ -15,7 +15,7 @@ module.exports = class ShardInfoCommand extends Command { memberName: 'shardinfo', description: 'Gives some bot info for the Shard you specify.', args: [{ - key: 'shardID', + key: 'shard', prompt: 'Which Shard would you like to get data for?', type: 'integer' }] @@ -26,26 +26,21 @@ module.exports = class ShardInfoCommand extends Command { if (message.channel.type !== 'dm') if (!message.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return message.say('This Command requires the `Embed Links` Permission.'); - const { shardID } = args; - if (shardID > this.client.options.shardCount - 1 || shardID < 0) + const { shard } = args; + if (shard > this.client.options.shardCount - 1 || shard < 0) 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'); const embed = new RichEmbed() + .setTitle(`Data for Shard ${shard}:`) .setColor(0x00AE86) .addField('Servers', - guilds[shardID], true) - .addField('Shard ID', - shardID, true) + guilds[shard], true) .addField('Memory Usage', - `${memory[shardID]}MB`, true) + `${memory[shard]}MB`, true) .addField('Uptime', - moment.duration(uptime[shardID]).format('d[d]h[h]m[m]s[s]'), true) - .addField('Version', - version, true) - .addField('Node Version', - process.version, true); + moment.duration(uptime[shard]).format('d[d]h[h]m[m]s[s]'), true); return message.embed(embed); } }; diff --git a/package.json b/package.json index 936a166e..13b95cb8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "16.4.2", + "version": "17.0.0", "description": "A Discord Bot", "main": "shardingmanager.js", "scripts": {