From dbcd5ec33a920766cc014293f4fe9f1a829e70ce Mon Sep 17 00:00:00 2001 From: loicbersier Date: Tue, 15 Jan 2019 21:57:33 +0100 Subject: [PATCH] fixed commands --- commands/images/fetish.js | 8 +++----- commands/images/god.js | 10 +++------- commands/images/idubbbz.js | 4 +--- commands/images/idubbbzpaint.js | 5 +---- commands/images/like.js | 5 +---- commands/images/ugly.js | 5 +---- 6 files changed, 10 insertions(+), 27 deletions(-) diff --git a/commands/images/fetish.js b/commands/images/fetish.js index 5a06759..4585a48 100644 --- a/commands/images/fetish.js +++ b/commands/images/fetish.js @@ -1,5 +1,4 @@ const { Command } = require('discord-akairo'); -const Discord = require('discord.js'); const { createCanvas, loadImage } = require('canvas'); const superagent = require('superagent'); @@ -11,7 +10,8 @@ class FetishCommand extends Command { args: [ { id: 'image', - type: 'string' + type: 'string', + optional: true, } ] }); @@ -40,10 +40,8 @@ class FetishCommand extends Command { const bg = await loadImage(buffer); ctx.drawImage(bg, 50, 50, 450, 450); - const attachment = new Discord.Attachment(canvas.toBuffer(), 'myfetish.png'); - - message.channel.send(attachment).catch(() => { + message.channel.send({files: [canvas.toBuffer()]}).catch(() => { message.channel.send('an error as occured. Check the bot/channel permissions'); }); } diff --git a/commands/images/god.js b/commands/images/god.js index b8d0ffd..50897dd 100644 --- a/commands/images/god.js +++ b/commands/images/god.js @@ -1,5 +1,4 @@ const { Command } = require('discord-akairo'); -const Discord = require('discord.js'); const { createCanvas, loadImage } = require('canvas'); const superagent = require('superagent'); @@ -41,13 +40,10 @@ class GodCommand extends Command { const bg = await loadImage(buffer); ctx.drawImage(bg, 0, 0, canvas.width, canvas.height); - const attachment = new Discord.Attachment(canvas.toBuffer(), 'god.png'); - message.delete(); - message.channel.send(attachment) - .catch(() => { - message.channel.send('an error as occured. Check the bot/channel permissions'); - }); + message.channel.send({files: [canvas.toBuffer()]}).catch(() => { + message.channel.send('an error as occured. Check the bot/channel permissions'); + }); } } diff --git a/commands/images/idubbbz.js b/commands/images/idubbbz.js index 9424a89..2ad1625 100644 --- a/commands/images/idubbbz.js +++ b/commands/images/idubbbz.js @@ -1,5 +1,4 @@ const { Command } = require('discord-akairo'); -const Discord = require('discord.js'); const { createCanvas, loadImage } = require('canvas'); const superagent = require('superagent'); @@ -65,9 +64,8 @@ class IdubbbzCommand extends Command { ctx.fillStyle = '#000000'; ctx.fillText(text, canvas.width / 2.1, canvas.height / 1.5); - const attachment = new Discord.Attachment(canvas.toBuffer(), 'edups.png'); - message.channel.send(attachment).catch(() => { + message.channel.send({files: [canvas.toBuffer()]}).catch(() => { message.channel.send('an error as occured. Check the bot/channel permissions'); }); } diff --git a/commands/images/idubbbzpaint.js b/commands/images/idubbbzpaint.js index 843f4f2..7edbb28 100644 --- a/commands/images/idubbbzpaint.js +++ b/commands/images/idubbbzpaint.js @@ -1,5 +1,4 @@ const { Command } = require('discord-akairo'); -const Discord = require('discord.js'); const { createCanvas, loadImage } = require('canvas'); const superagent = require('superagent'); @@ -64,9 +63,7 @@ class IdubbbzPaintCommand extends Command { ctx.fillStyle = '#ffffff'; ctx.fillText(text, canvas.width / 3, canvas.height / 1.1); - const attachment = new Discord.Attachment(canvas.toBuffer(), 'edupspaint.png'); - - message.channel.send(attachment).catch(() => { + message.channel.send({files: [canvas.toBuffer()]}).catch(() => { message.channel.send('an error as occured. Check the bot/channel permissions'); }); } diff --git a/commands/images/like.js b/commands/images/like.js index 56571f1..c3545cc 100644 --- a/commands/images/like.js +++ b/commands/images/like.js @@ -1,5 +1,4 @@ const { Command } = require('discord-akairo'); -const Discord = require('discord.js'); const { createCanvas, loadImage } = require('canvas'); const superagent = require('superagent'); @@ -41,9 +40,7 @@ class LikeCommand extends Command { const bg = await loadImage(buffer); ctx.drawImage(bg, 0, 0, canvas.width, canvas.height); - const attachment = new Discord.Attachment(canvas.toBuffer(), 'like.png'); - - message.channel.send(attachment).catch(() => { + message.channel.send({files: [canvas.toBuffer()]}).catch(() => { message.channel.send('an error as occured. Check the bot/channel permissions'); }); } diff --git a/commands/images/ugly.js b/commands/images/ugly.js index 005f3de..7506820 100644 --- a/commands/images/ugly.js +++ b/commands/images/ugly.js @@ -1,5 +1,4 @@ const { Command } = require('discord-akairo'); -const Discord = require('discord.js'); const { createCanvas, loadImage } = require('canvas'); const superagent = require('superagent'); @@ -41,9 +40,7 @@ class UglyCommand extends Command { const bg = await loadImage(buffer); ctx.drawImage(bg, 40, 100, 250, 250); - const attachment = new Discord.Attachment(canvas.toBuffer(), 'ugly.png'); - - message.channel.send(attachment).catch(() => { + message.channel.send({files: [canvas.toBuffer()]}).catch(() => { message.channel.send('an error as occured. Check the bot/channel permissions'); }); }