From 8d271be6a34f9f8f7562bb870f77b110635e48db Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sat, 13 Oct 2018 12:13:38 +0200 Subject: [PATCH] fixed despacito normal behaviour --- commands/fun/despacito.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/commands/fun/despacito.js b/commands/fun/despacito.js index 11d8d982..cd62ac5b 100644 --- a/commands/fun/despacito.js +++ b/commands/fun/despacito.js @@ -22,25 +22,24 @@ module.exports = class DespacitoCommand extends Command { } async run(message, { user }) { - const canvas = createCanvas(660, 660); - const ctx = canvas.getContext('2d'); - const background = await loadImage(user.avatarURL); - ctx.drawImage(background, 5, 12, canvas.width, canvas.height); - const { body: buffer } = await superagent.get('https://image.noelshack.com/fichiers/2018/41/6/1539381851-untitled.png'); - const bg = await loadImage(buffer); - ctx.drawImage(bg, 0, 0, canvas.width, canvas.height); - const attachment = new Discord.Attachment(canvas.toBuffer(), 'despacito.png'); - if (!user) { const number = Object.keys(responseObject).length; const despacitoNumber = Math.floor (Math.random() * (number - 1 + 1)) + 1; - if (!user) - return message.channel.send({files: [responseObject[despacitoNumber]]}); - } else if (user.id === message.author.id) { + return message.channel.send({files: [responseObject[despacitoNumber]]}); + } else if (user.id === message.author.id) { return message.say(`Did you just try to despacitoad yourself?`); } else if (user.id === this.client.user.id) { return message.say('Nice try but you wont get me :^)'); } else { + const canvas = createCanvas(660, 660); + const ctx = canvas.getContext('2d'); + const background = await loadImage(user.avatarURL); + ctx.drawImage(background, 5, 12, canvas.width, canvas.height); + const { body: buffer } = await superagent.get('https://image.noelshack.com/fichiers/2018/41/6/1539381851-untitled.png'); + const bg = await loadImage(buffer); + ctx.drawImage(bg, 0, 0, canvas.width, canvas.height); + const attachment = new Discord.Attachment(canvas.toBuffer(), 'despacito.png'); + message.delete(); message.say(`${user}, you have been despacitoad`, attachment); }