From c2f06d25b19f772498c2c5210799af8378c73497 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Thu, 23 Mar 2017 22:07:48 +0000 Subject: [PATCH] All Avatar Edit Commands have been async-ified --- commands/avataredit/beautiful.js | 21 ++++++++++----------- commands/avataredit/bobross.js | 17 ++++++++--------- commands/avataredit/rip.js | 17 ++++++++--------- commands/avataredit/steamcard.js | 24 +++++++++++------------- commands/random/quiz.js | 2 +- 5 files changed, 38 insertions(+), 43 deletions(-) diff --git a/commands/avataredit/beautiful.js b/commands/avataredit/beautiful.js index e10a4016..de0baaa4 100644 --- a/commands/avataredit/beautiful.js +++ b/commands/avataredit/beautiful.js @@ -21,11 +21,11 @@ module.exports = class BeautifulCommand extends commando.Command { } console.log(`[Command] ${message.content}`); if (message.mentions.users.size !== 1) { - return message.channel.send(':x: Error! Please mention one user!'); + let errorMes1 = await message.channel.send(':x: Error! Please mention one user!'); } else { if (!message.mentions.users.first().avatarURL) { - return message.channel.send(":x: Error! This user has no avatar!"); + let errorMes2 = await message.channel.send(":x: Error! This user has no avatar!"); } else { let userAvatar = message.mentions.users.first().avatarURL; @@ -34,15 +34,14 @@ module.exports = class BeautifulCommand extends commando.Command { let images = []; images.push(Jimp.read(userAvatar)); images.push(Jimp.read("./images/beautiful.jpg")); - await Promise.all(images).then(([avatar, beautiful]) => { - avatar.resize(200, 200); - beautiful.blit(avatar, 432, 42); - avatar.resize(190, 190); - beautiful.blit(avatar, 451, 434); - beautiful.getBuffer(Jimp.MIME_PNG, (err, buff) => { - if (err) throw err; - return message.channel.sendFile(buff); - }); + let [avatar, beautiful] = await Promise.all(images); + avatar.resize(200, 200); + beautiful.blit(avatar, 432, 42); + avatar.resize(190, 190); + beautiful.blit(avatar, 451, 434); + beautiful.getBuffer(Jimp.MIME_PNG, (err, buff) => { + if (err) throw err; + message.channel.sendFile(buff); }); } } diff --git a/commands/avataredit/bobross.js b/commands/avataredit/bobross.js index b03045c9..bf358933 100644 --- a/commands/avataredit/bobross.js +++ b/commands/avataredit/bobross.js @@ -36,15 +36,14 @@ module.exports = class BobRossCommand extends commando.Command { images.push(Jimp.read(userAvatar)); images.push(Jimp.read("./images/BobRoss.png")); images.push(Jimp.read("./images/BlankWhite.png")); - await Promise.all(images).then(([avatar, bob, nothing]) => { - avatar.rotate(2); - avatar.resize(300, 300); - nothing.composite(avatar, 44, 85); - nothing.composite(bob, 0, 0); - nothing.getBuffer(Jimp.MIME_PNG, (err, buff) => { - if (err) throw err; - return message.channel.sendFile(buff); - }); + let [avatar, bob, nothing] = await Promise.all(images); + avatar.rotate(2); + avatar.resize(300, 300); + nothing.composite(avatar, 44, 85); + nothing.composite(bob, 0, 0); + nothing.getBuffer(Jimp.MIME_PNG, (err, buff) => { + if (err) throw err; + message.channel.sendFile(buff); }); } } diff --git a/commands/avataredit/rip.js b/commands/avataredit/rip.js index edf35bfb..9b0b542c 100644 --- a/commands/avataredit/rip.js +++ b/commands/avataredit/rip.js @@ -22,11 +22,11 @@ module.exports = class RIPCommand extends commando.Command { } console.log(`[Command] ${message.content}`); if (message.mentions.users.size !== 1) { - return message.channel.send(':x: Error! Please mention one user!'); + let errorMes1 = await message.channel.send(':x: Error! Please mention one user!'); } else { if (!message.mentions.users.first().avatarURL) { - return message.channel.send(":x: Error! This user has no avatar!"); + let errorMes2 = await message.channel.send(":x: Error! This user has no avatar!"); } else { let userAvatar = message.mentions.users.first().avatarURL; @@ -35,13 +35,12 @@ module.exports = class RIPCommand extends commando.Command { let images = []; images.push(Jimp.read(userAvatar)); images.push(Jimp.read("./images/gravestone.jpg")); - await Promise.all(images).then(([avatar, gravestone]) => { - avatar.resize(200, 200); - gravestone.blit(avatar, 60, 65); - gravestone.getBuffer(Jimp.MIME_PNG, (err, buff) => { - if (err) throw err; - return message.channel.sendFile(buff); - }); + let [avatar, gravestone] = await Promise.all(images); + avatar.resize(200, 200); + gravestone.blit(avatar, 60, 65); + gravestone.getBuffer(Jimp.MIME_PNG, (err, buff) => { + if (err) throw err; + message.channel.sendFile(buff); }); } } diff --git a/commands/avataredit/steamcard.js b/commands/avataredit/steamcard.js index ff4480a4..1a082ff6 100644 --- a/commands/avataredit/steamcard.js +++ b/commands/avataredit/steamcard.js @@ -22,11 +22,11 @@ module.exports = class SteamCardCommand extends commando.Command { console.log(`[Command] ${message.content}`); if (message.channel.type !== 'dm') { if (message.mentions.users.size !== 1) { - return message.channel.send(':x: Error! Please mention one user!'); + let errorMes1 = await message.channel.send(':x: Error! Please mention one user!'); } else { if (!message.mentions.users.first().avatarURL) { - return message.channel.send(":x: Error! This user has no avatar!"); + let errorMes2 = await message.channel.send(":x: Error! This user has no avatar!"); } else { let userDisplayName = message.guild.member(message.mentions.users.first()).displayName; @@ -37,17 +37,15 @@ module.exports = class SteamCardCommand extends commando.Command { images.push(Jimp.read(userAvatar)); images.push(Jimp.read("./images/SteamCard.png")); images.push(Jimp.read("./images/SteamCardBlank.png")); - await Promise.all(images).then(([avatar, steamcard, nothing]) => { - Jimp.loadFont(Jimp.FONT_SANS_32_WHITE).then(function(font) { - avatar.resize(450, 450); - nothing.composite(avatar, 25, 25); - nothing.composite(steamcard, 0, 0); - nothing.print(font, 38, 20, userDisplayName); - nothing.getBuffer(Jimp.MIME_PNG, (err, buff) => { - if (err) throw err; - return message.channel.sendFile(buff); - }); - }); + let [avatar, steamcard, nothing] = await Promise.all(images); + let font = await Jimp.loadFont(Jimp.FONT_SANS_32_WHITE); + avatar.resize(450, 450); + nothing.composite(avatar, 25, 25); + nothing.composite(steamcard, 0, 0); + nothing.print(font, 38, 20, userDisplayName); + nothing.getBuffer(Jimp.MIME_PNG, (err, buff) => { + if (err) throw err; + message.channel.sendFile(buff); }); } } diff --git a/commands/random/quiz.js b/commands/random/quiz.js index 5cbe6b4b..f89cd904 100644 --- a/commands/random/quiz.js +++ b/commands/random/quiz.js @@ -29,7 +29,7 @@ module.exports = class QuizCommand extends commando.Command { }); const embed = new Discord.RichEmbed() .setTitle('You have **fifteen** seconds to answer this question:') - .setDescription(`**Category: ${response.body[0].category}**\n${response.body[0].question}`); + .setDescription(`**Category: ${response.body[0].category.title}**\n${response.body[0].question}`); let embededMessage = await message.channel.sendEmbed(embed); try { let collected = await message.channel.awaitMessages(res => res.content.toLowerCase() === response.body[0].answer.toLowerCase() && res.author.id === message.author.id, {