diff --git a/commands/fun/despacito.js b/commands/fun/despacito.js index 05ce15de..11d8d982 100644 --- a/commands/fun/despacito.js +++ b/commands/fun/despacito.js @@ -1,5 +1,8 @@ const { Command } = require('discord.js-commando'); const responseObject = require("../../json/despacito.json"); +const { createCanvas, loadImage, getContext } = require('canvas') +const superagent = require('superagent') +const Discord = require('discord.js'); module.exports = class DespacitoCommand extends Command { constructor(client) { super(client, { @@ -11,7 +14,7 @@ module.exports = class DespacitoCommand extends Command { { key: 'user', prompt: 'What do you want me to say', - type: 'member', + type: 'user', default: '' } ] @@ -19,6 +22,15 @@ 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; @@ -28,8 +40,11 @@ module.exports = class DespacitoCommand extends Command { 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 + } else { message.delete(); - message.say(`${user}, you have been despacitoad`); - } + message.say(`${user}, you have been despacitoad`, attachment); + } + + +} }; \ No newline at end of file diff --git a/package.json b/package.json index 3f4c3945..b08549fc 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ }, "homepage": "https://gitlab.com/loicbersier/discordbot#readme", "dependencies": { + "canvas": "^2.0.0-alpha.18", "discord.js": "^11.4.2", "discord.js-commando": "^0.10.0", "faceapp": "^0.4.4",