From 8a5af838446b423e59ef5479bc440c68f996da3d Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Fri, 3 May 2024 01:49:01 -0400 Subject: [PATCH] napi-rs/canvas doesn't support line breaks???? --- commands/analyze/aspect-ratio.js | 2 +- commands/analyze/dominant-color.js | 4 ++-- commands/analyze/faces.js | 4 ++-- commands/analyze/image-size.js | 2 +- commands/edit-avatar/avatar-fusion.js | 4 ++-- commands/edit-avatar/eject.js | 2 +- commands/edit-avatar/hat.js | 4 ++-- commands/edit-avatar/he-lives-in-you.js | 4 ++-- commands/edit-avatar/hearts.js | 4 ++-- commands/edit-avatar/i-have-the-power.js | 4 ++-- commands/edit-avatar/rip.js | 4 ++-- commands/edit-avatar/steam-now-playing.js | 4 ++-- commands/edit-avatar/triggered.js | 2 +- commands/edit-face/anime-eyes.js | 4 ++-- commands/edit-face/danny-devito.js | 4 ++-- commands/edit-face/emoji-face.js | 4 ++-- commands/edit-face/eyes.js | 4 ++-- commands/edit-face/shrek.js | 4 ++-- commands/edit-image-text/ace-attorney.js | 4 ++-- commands/edit-image-text/achievement.js | 4 ++-- commands/edit-image-text/axis-cult-sign-up.js | 2 +- commands/edit-image-text/caution.js | 4 ++-- commands/edit-image-text/certificate.js | 4 ++-- commands/edit-image-text/chinese-restaurant.js | 4 ++-- commands/edit-image-text/danger.js | 4 ++-- commands/edit-image-text/font.js | 4 ++-- commands/edit-image-text/gandhi-quote.js | 4 ++-- commands/edit-image-text/highway-sign.js | 4 ++-- commands/edit-image-text/hollywood-star.js | 4 ++-- commands/edit-image-text/jeopardy-question.js | 4 ++-- commands/edit-image-text/license-plate.js | 4 ++-- commands/edit-image-text/speed-limit.js | 4 ++-- commands/edit-image-text/spongebob-time-card.js | 4 ++-- commands/edit-image-text/tweet.js | 4 ++-- commands/edit-image-text/undertale.js | 4 ++-- commands/edit-image-text/zero-dialogue.js | 4 ++-- commands/edit-image/analog-clock.js | 4 ++-- commands/edit-image/approved.js | 4 ++-- commands/edit-image/ascii.js | 2 +- commands/edit-image/blur.js | 4 ++-- commands/edit-image/bob-ross.js | 4 ++-- commands/edit-image/brazzers.js | 4 ++-- commands/edit-image/chocolate-milk.js | 4 ++-- commands/edit-image/circle.js | 4 ++-- commands/edit-image/color.js | 4 ++-- commands/edit-image/communist.js | 4 ++-- commands/edit-image/contrast.js | 4 ++-- commands/edit-image/convert-image.js | 2 +- commands/edit-image/crop-to-content.js | 4 ++-- commands/edit-image/desaturate.js | 4 ++-- commands/edit-image/dexter.js | 4 ++-- commands/edit-image/distort.js | 4 ++-- commands/edit-image/fire-frame.js | 4 ++-- commands/edit-image/fish-eye.js | 4 ++-- commands/edit-image/frame.js | 4 ++-- commands/edit-image/ghost.js | 4 ++-- commands/edit-image/glass-shatter.js | 4 ++-- commands/edit-image/glitch.js | 4 ++-- commands/edit-image/greyscale.js | 4 ++-- commands/edit-image/gun.js | 4 ++-- commands/edit-image/hands.js | 4 ++-- commands/edit-image/ifunny.js | 4 ++-- commands/edit-image/invert.js | 4 ++-- commands/edit-image/lego-icon.js | 4 ++-- commands/edit-image/mirror.js | 4 ++-- commands/edit-image/motion-blur.js | 4 ++-- commands/edit-image/needs-more-jpeg.js | 2 +- commands/edit-image/pet.js | 2 +- commands/edit-image/pixelize.js | 4 ++-- commands/edit-image/police-tape.js | 4 ++-- commands/edit-image/rainbow.js | 4 ++-- commands/edit-image/rejected.js | 4 ++-- commands/edit-image/resize.js | 4 ++-- commands/edit-image/rotate.js | 4 ++-- commands/edit-image/sepia.js | 4 ++-- commands/edit-image/shake.js | 2 +- commands/edit-image/silhouette.js | 4 ++-- commands/edit-image/sip.js | 4 ++-- commands/edit-image/snapchat.js | 4 ++-- commands/edit-image/spotify-now-playing.js | 4 ++-- commands/edit-image/square.js | 4 ++-- commands/edit-image/steam-card.js | 4 ++-- commands/edit-image/subtitle.js | 4 ++-- commands/edit-image/tint.js | 4 ++-- commands/edit-image/vignette.js | 4 ++-- commands/edit-image/wanted.js | 4 ++-- commands/edit-image/wild-pokemon.js | 4 ++-- commands/edit-image/you-died.js | 4 ++-- commands/edit-image/yu-gi-oh-gen.js | 4 ++-- commands/edit-meme/3000-years.js | 4 ++-- commands/edit-meme/alert.js | 4 ++-- commands/edit-meme/bart-chalkboard.js | 4 ++-- commands/edit-meme/be-like-bill.js | 4 ++-- commands/edit-meme/beautiful.js | 4 ++-- commands/edit-meme/boardroom-meeting.js | 4 ++-- commands/edit-meme/catch.js | 4 ++-- commands/edit-meme/challenger.js | 4 ++-- commands/edit-meme/change-my-mind.js | 4 ++-- commands/edit-meme/chi-idea.js | 4 ++-- commands/edit-meme/crush.js | 4 ++-- commands/edit-meme/cursed-sponge.js | 4 ++-- commands/edit-meme/dear-liberals.js | 4 ++-- commands/edit-meme/deep-fry.js | 2 +- commands/edit-meme/demotivational.js | 4 ++-- commands/edit-meme/dislike.js | 4 ++-- commands/edit-meme/distracted-boyfriend.js | 4 ++-- commands/edit-meme/drakeposting.js | 4 ++-- commands/edit-meme/edd-facts-book.js | 4 ++-- commands/edit-meme/enslaved.js | 4 ++-- commands/edit-meme/food-broke.js | 4 ++-- commands/edit-meme/for-five-hours.js | 4 ++-- commands/edit-meme/genie-rules.js | 4 ++-- commands/edit-meme/girl-worth-fighting-for.js | 4 ++-- commands/edit-meme/gru-plan.js | 4 ++-- commands/edit-meme/i-cant-believe.js | 4 ++-- commands/edit-meme/i-fear-no-man.js | 4 ++-- commands/edit-meme/if-those-kids-could-read.js | 4 ++-- commands/edit-meme/kyon-gun.js | 4 ++-- commands/edit-meme/like.js | 4 ++-- commands/edit-meme/lisa-presentation.js | 4 ++-- commands/edit-meme/look-at-this-photograph.js | 4 ++-- commands/edit-meme/look-what-karen-have.js | 4 ++-- commands/edit-meme/mario-bros-views.js | 4 ++-- commands/edit-meme/meme-gen.js | 4 ++-- commands/edit-meme/metamorphosis.js | 4 ++-- commands/edit-meme/my-collection-grows.js | 4 ++-- commands/edit-meme/new-password.js | 4 ++-- commands/edit-meme/nike-ad.js | 4 ++-- commands/edit-meme/panik-kalm-panik.js | 4 ++-- commands/edit-meme/phoebe-teaching-joey.js | 4 ++-- commands/edit-meme/pills.js | 4 ++-- commands/edit-meme/plankton-plan.js | 4 ++-- commands/edit-meme/raw.js | 4 ++-- commands/edit-meme/reaction-meme.js | 4 ++-- commands/edit-meme/scroll-of-truth.js | 4 ++-- commands/edit-meme/sexy-singles.js | 4 ++-- commands/edit-meme/skyrim-skill.js | 4 ++-- commands/edit-meme/sonic-says.js | 4 ++-- commands/edit-meme/sora-selfie.js | 4 ++-- commands/edit-meme/sos.js | 4 ++-- commands/edit-meme/spiderman-pointing.js | 4 ++-- commands/edit-meme/spongebob-burn.js | 4 ++-- commands/edit-meme/that-sign-wont-stop-me.js | 4 ++-- commands/edit-meme/this-guy.js | 4 ++-- commands/edit-meme/thug-life.js | 4 ++-- commands/edit-meme/to-be-continued.js | 4 ++-- commands/edit-meme/tuxedo-pooh.js | 4 ++-- commands/edit-meme/two-buttons.js | 4 ++-- commands/edit-meme/ugly.js | 4 ++-- commands/edit-meme/ultimate-tattoo.js | 4 ++-- commands/edit-meme/vietnam-flashbacks.js | 4 ++-- commands/edit-meme/whiteboard.js | 4 ++-- commands/edit-meme/worse-than-hitler.js | 4 ++-- commands/edit-meme/worthless.js | 4 ++-- commands/games-mp/car-race.js | 4 ++-- commands/games-mp/chess.js | 4 ++-- commands/games-sp/captcha.js | 4 ++-- commands/games-sp/horse-race.js | 4 ++-- commands/games-sp/jeopardy.js | 4 ++-- commands/games-sp/pokemon-advantage.js | 4 ++-- commands/games-sp/typing-test.js | 4 ++-- commands/games-sp/whos-that-pokemon.js | 4 ++-- commands/info/emoji-image.js | 4 ++-- commands/pokedex/pokedex-box-sprite.js | 4 ++-- commands/random-seed/friendship.js | 4 ++-- commands/random-seed/ship.js | 4 ++-- commands/random-seed/think-of.js | 4 ++-- commands/search/periodic-table.js | 4 ++-- package.json | 2 +- structures/fonts/Font.js | 4 ++-- structures/pokemon/Pokemon.js | 4 ++-- structures/pokemon/PokemonStore.js | 2 +- util/Canvas.js | 2 +- 173 files changed, 332 insertions(+), 332 deletions(-) diff --git a/commands/analyze/aspect-ratio.js b/commands/analyze/aspect-ratio.js index 62182ef8..26d6d49a 100644 --- a/commands/analyze/aspect-ratio.js +++ b/commands/analyze/aspect-ratio.js @@ -1,5 +1,5 @@ const Command = require('../../framework/Command'); -const { loadImage } = require('@napi-rs/canvas'); +const { loadImage } = require('canvas'); const request = require('node-superfetch'); const { gcd } = require('../../util/Util'); diff --git a/commands/analyze/dominant-color.js b/commands/analyze/dominant-color.js index 32172679..a3828f75 100644 --- a/commands/analyze/dominant-color.js +++ b/commands/analyze/dominant-color.js @@ -1,5 +1,5 @@ const Command = require('../../framework/Command'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const ntc = require('ntcjs'); const { rgbToHex } = require('../../util/Util'); @@ -37,7 +37,7 @@ module.exports = class DominantColorCommand extends Command { ctx.fillRect(0, 0, canvas.width, canvas.height); const name = ntc.name(hexColor); return msg.say(`${hexColor.toUpperCase()} - ${name[1]}`, { - files: [{ attachment: canvas.toBuffer('image/png'), name: 'dominant-color.png' }] + files: [{ attachment: canvas.toBuffer(), name: 'dominant-color.png' }] }); } }; diff --git a/commands/analyze/faces.js b/commands/analyze/faces.js index feee488f..763cec54 100644 --- a/commands/analyze/faces.js +++ b/commands/analyze/faces.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const request = require('node-superfetch'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); module.exports = class FacesCommand extends Command { constructor(client) { @@ -40,6 +40,6 @@ module.exports = class FacesCommand extends Command { ctx.fillRect(face.box.xMin, face.box.yMax, face.box.width + lineSize, lineSize); ctx.fillRect(face.box.xMax, face.box.yMin, lineSize, face.box.height); } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'faces.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'faces.png' }] }); } }; diff --git a/commands/analyze/image-size.js b/commands/analyze/image-size.js index e6fc9024..ae82a633 100644 --- a/commands/analyze/image-size.js +++ b/commands/analyze/image-size.js @@ -1,5 +1,5 @@ const Command = require('../../framework/Command'); -const { loadImage } = require('@napi-rs/canvas'); +const { loadImage } = require('canvas'); const request = require('node-superfetch'); module.exports = class ImageSizeCommand extends Command { diff --git a/commands/edit-avatar/avatar-fusion.js b/commands/edit-avatar/avatar-fusion.js index 85ebc361..49fc9fc9 100644 --- a/commands/edit-avatar/avatar-fusion.js +++ b/commands/edit-avatar/avatar-fusion.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); module.exports = class AvatarFusionCommand extends Command { @@ -42,6 +42,6 @@ module.exports = class AvatarFusionCommand extends Command { ctx.globalAlpha = 0.5; ctx.drawImage(baseAvatar, 0, 0); ctx.drawImage(overlayAvatar, 0, 0, baseAvatar.width, baseAvatar.height); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'avatar-fusion.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'avatar-fusion.png' }] }); } }; diff --git a/commands/edit-avatar/eject.js b/commands/edit-avatar/eject.js index eb86616c..acbb0d91 100644 --- a/commands/edit-avatar/eject.js +++ b/commands/edit-avatar/eject.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const GIFEncoder = require('gifencoder'); const { MersenneTwister19937, bool } = require('random-js'); const request = require('node-superfetch'); diff --git a/commands/edit-avatar/hat.js b/commands/edit-avatar/hat.js index 7fc25901..aebd95f8 100644 --- a/commands/edit-avatar/hat.js +++ b/commands/edit-avatar/hat.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const hats = require('../../assets/json/hat'); @@ -154,6 +154,6 @@ module.exports = class HatCommand extends Command { ctx.drawImage(avatar, 0, 0); ctx.drawImage(base, 0, 0, avatar.width, avatar.height); const comment = user.id === this.client.user.id ? hat.commentMe : hat.comment.replace(/{{user}}/g, user.tag); - return msg.say(comment, { files: [{ attachment: canvas.toBuffer('image/png'), name: `${type}-hat.png` }] }); + return msg.say(comment, { files: [{ attachment: canvas.toBuffer(), name: `${type}-hat.png` }] }); } }; diff --git a/commands/edit-avatar/he-lives-in-you.js b/commands/edit-avatar/he-lives-in-you.js index 09b35a2e..0a12b8b8 100644 --- a/commands/edit-avatar/he-lives-in-you.js +++ b/commands/edit-avatar/he-lives-in-you.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { drawImageWithTint } = require('../../util/Canvas'); @@ -47,6 +47,6 @@ module.exports = class HeLivesInYouCommand extends Command { ctx.rotate(-24 * (Math.PI / 180)); drawImageWithTint(ctx, avatar, '#00115d', 75, 160, 130, 150); ctx.rotate(24 * (Math.PI / 180)); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'he-lives-in-you.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'he-lives-in-you.png' }] }); } }; diff --git a/commands/edit-avatar/hearts.js b/commands/edit-avatar/hearts.js index 9c5577bb..fb20acca 100644 --- a/commands/edit-avatar/hearts.js +++ b/commands/edit-avatar/hearts.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { drawImageWithTint } = require('../../util/Canvas'); @@ -45,6 +45,6 @@ module.exports = class HeartsCommand extends Command { const ctx = canvas.getContext('2d'); drawImageWithTint(ctx, avatar, 'deeppink', 0, 0, avatar.width, avatar.height); ctx.drawImage(base, 0, 0, avatar.width, avatar.height); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'hearts.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'hearts.png' }] }); } }; diff --git a/commands/edit-avatar/i-have-the-power.js b/commands/edit-avatar/i-have-the-power.js index c3a7d046..4aa2ba55 100644 --- a/commands/edit-avatar/i-have-the-power.js +++ b/commands/edit-avatar/i-have-the-power.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); @@ -45,6 +45,6 @@ module.exports = class IHaveThePowerCommand extends Command { ctx.rotate(18.3 * (Math.PI / 180)); ctx.drawImage(avatar, 332, -125, 175, 175); ctx.rotate(-18.3 * (Math.PI / 180)); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'i-have-the-power.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'i-have-the-power.png' }] }); } }; diff --git a/commands/edit-avatar/rip.js b/commands/edit-avatar/rip.js index 2d32aa00..688bd423 100644 --- a/commands/edit-avatar/rip.js +++ b/commands/edit-avatar/rip.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { greyscale } = require('../../util/Canvas'); @@ -67,6 +67,6 @@ module.exports = class RipCommand extends Command { if (cause) ctx.fillText(cause, 438, 910, 500); ctx.font = this.client.fonts.get('CoffinStone.otf').toCanvasString(37); ctx.fillText('In Loving Memory of', 438, 292); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'rip.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'rip.png' }] }); } }; diff --git a/commands/edit-avatar/steam-now-playing.js b/commands/edit-avatar/steam-now-playing.js index 2607ef81..bf2e52e5 100644 --- a/commands/edit-avatar/steam-now-playing.js +++ b/commands/edit-avatar/steam-now-playing.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { shortenText } = require('../../util/Canvas'); @@ -58,6 +58,6 @@ module.exports = class SteamNowPlayingCommand extends Command { ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(14); ctx.fillText(user.username, 80, 34); ctx.fillText(shortenText(ctx, game, 200), 80, 70); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'steam-now-playing.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'steam-now-playing.png' }] }); } }; diff --git a/commands/edit-avatar/triggered.js b/commands/edit-avatar/triggered.js index ec86664f..6652ace4 100644 --- a/commands/edit-avatar/triggered.js +++ b/commands/edit-avatar/triggered.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const GIFEncoder = require('gifencoder'); const request = require('node-superfetch'); const path = require('path'); diff --git a/commands/edit-face/anime-eyes.js b/commands/edit-face/anime-eyes.js index beda7d8c..6b77240b 100644 --- a/commands/edit-face/anime-eyes.js +++ b/commands/edit-face/anime-eyes.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const request = require('node-superfetch'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); module.exports = class AnimeEyesCommand extends Command { @@ -47,6 +47,6 @@ module.exports = class AnimeEyesCommand extends Command { ctx.drawImage(rightEye, leftEyeX, leftEyeY, eyeWidth, eyeHeight); ctx.drawImage(leftEye, rightEyeX, rightEyeY, eyeWidth, eyeHeight); } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'anime-eyes.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'anime-eyes.png' }] }); } }; diff --git a/commands/edit-face/danny-devito.js b/commands/edit-face/danny-devito.js index a77a4173..9cb79b6e 100644 --- a/commands/edit-face/danny-devito.js +++ b/commands/edit-face/danny-devito.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const request = require('node-superfetch'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); module.exports = class DannyDevitoCommand extends Command { @@ -52,6 +52,6 @@ module.exports = class DannyDevitoCommand extends Command { height * 1.4 ); } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'danny-devito.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'danny-devito.png' }] }); } }; diff --git a/commands/edit-face/emoji-face.js b/commands/edit-face/emoji-face.js index 62ea5a9d..0a05f8bc 100644 --- a/commands/edit-face/emoji-face.js +++ b/commands/edit-face/emoji-face.js @@ -1,7 +1,7 @@ const Command = require('../../framework/Command'); const { GuildEmoji } = require('discord.js'); const request = require('node-superfetch'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const twemoji = require('@twemoji/parser'); module.exports = class EmojiFaceCommand extends Command { @@ -63,6 +63,6 @@ module.exports = class EmojiFaceCommand extends Command { height * 1.4 ); } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'emoji-face.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'emoji-face.png' }] }); } }; diff --git a/commands/edit-face/eyes.js b/commands/edit-face/eyes.js index ed3d653b..639ac0a2 100644 --- a/commands/edit-face/eyes.js +++ b/commands/edit-face/eyes.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const request = require('node-superfetch'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); module.exports = class EyesCommand extends Command { @@ -45,6 +45,6 @@ module.exports = class EyesCommand extends Command { ctx.drawImage(eyes, leftEyeX, leftEyeY, eyeWidth, eyeHeight); ctx.drawImage(eyes, rightEyeX, rightEyeY, eyeWidth, eyeHeight); } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'eyes.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'eyes.png' }] }); } }; diff --git a/commands/edit-face/shrek.js b/commands/edit-face/shrek.js index 839d8c17..0c567b5d 100644 --- a/commands/edit-face/shrek.js +++ b/commands/edit-face/shrek.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const request = require('node-superfetch'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); module.exports = class ShrekCommand extends Command { @@ -52,6 +52,6 @@ module.exports = class ShrekCommand extends Command { height * 1.5 ); } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'shrek.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'shrek.png' }] }); } }; diff --git a/commands/edit-image-text/ace-attorney.js b/commands/edit-image-text/ace-attorney.js index b0df8cbb..f7be33a9 100644 --- a/commands/edit-image-text/ace-attorney.js +++ b/commands/edit-image-text/ace-attorney.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { firstUpperCase } = require('../../util/Util'); const { wrapText } = require('../../util/Canvas'); @@ -83,6 +83,6 @@ module.exports = class AceAttorneyCommand extends Command { let text = wrapText(ctx, quote, 242); text = text.length > 5 ? `${text.slice(0, 5).join('\n')}...` : text.join('\n'); ctx.fillText(text, 7, 199); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: `ace-attorney-${character}.png` }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: `ace-attorney-${character}.png` }] }); } }; diff --git a/commands/edit-image-text/achievement.js b/commands/edit-image-text/achievement.js index 25bff751..41af8c41 100644 --- a/commands/edit-image-text/achievement.js +++ b/commands/edit-image-text/achievement.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { shortenText } = require('../../util/Canvas'); @@ -56,6 +56,6 @@ module.exports = class AchievementCommand extends Command { ctx.fillText('Achievement Get!', 60, 40); ctx.fillStyle = '#ffffff'; ctx.fillText(shortenText(ctx, text, 230), 60, 60); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'achievement.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'achievement.png' }] }); } }; diff --git a/commands/edit-image-text/axis-cult-sign-up.js b/commands/edit-image-text/axis-cult-sign-up.js index dbe4d11a..357ac67f 100644 --- a/commands/edit-image-text/axis-cult-sign-up.js +++ b/commands/edit-image-text/axis-cult-sign-up.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); module.exports = class AxisCultSignUpCommand extends Command { diff --git a/commands/edit-image-text/caution.js b/commands/edit-image-text/caution.js index 31f78afc..b442c806 100644 --- a/commands/edit-image-text/caution.js +++ b/commands/edit-image-text/caution.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); @@ -60,6 +60,6 @@ module.exports = class CautionCommand extends Command { const height = topMost + ((fontSize + 20) * i); ctx.fillText(lines[i], base.width / 2, height); } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'caution.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'caution.png' }] }); } }; diff --git a/commands/edit-image-text/certificate.js b/commands/edit-image-text/certificate.js index 228d11d3..e6b2e9fb 100644 --- a/commands/edit-image-text/certificate.js +++ b/commands/edit-image-text/certificate.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const moment = require('moment'); const path = require('path'); @@ -63,6 +63,6 @@ module.exports = class CertificateCommand extends Command { ctx.fillText(reason, 518, 273); ctx.fillText(name, 518, 419); ctx.fillText(moment().format('MM/DD/YYYY'), 309, 503); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'certificate.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'certificate.png' }] }); } }; diff --git a/commands/edit-image-text/chinese-restaurant.js b/commands/edit-image-text/chinese-restaurant.js index 6458ef27..d57407f2 100644 --- a/commands/edit-image-text/chinese-restaurant.js +++ b/commands/edit-image-text/chinese-restaurant.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); @@ -65,6 +65,6 @@ module.exports = class ChineseRestaurantCommand extends Command { ctx.fillText(lines[2], base.width / 2, 315); ctx.fillText(lines[3], base.width / 2, 342); } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'chinese-restaurant.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'chinese-restaurant.png' }] }); } }; diff --git a/commands/edit-image-text/danger.js b/commands/edit-image-text/danger.js index 4c184723..c6ae5d3a 100644 --- a/commands/edit-image-text/danger.js +++ b/commands/edit-image-text/danger.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); @@ -60,6 +60,6 @@ module.exports = class DangerCommand extends Command { const height = topMost + ((fontSize + 20) * i); ctx.fillText(lines[i], base.width / 2, height); } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'danger.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'danger.png' }] }); } }; diff --git a/commands/edit-image-text/font.js b/commands/edit-image-text/font.js index a18b818e..30a9667d 100644 --- a/commands/edit-image-text/font.js +++ b/commands/edit-image-text/font.js @@ -1,5 +1,5 @@ const Command = require('../../framework/Command'); -const { createCanvas } = require('@napi-rs/canvas'); +const { createCanvas } = require('canvas'); const { wrapText } = require('../../util/Canvas'); module.exports = class FontCommand extends Command { @@ -47,6 +47,6 @@ module.exports = class FontCommand extends Command { ctx.fillRect(0, 0, canvas.width, canvas.height); ctx.fillStyle = 'black'; ctx.fillText(lines.join('\n'), 25, 25); - return canvas.toBuffer('image/png'); + return canvas.toBuffer(); } }; diff --git a/commands/edit-image-text/gandhi-quote.js b/commands/edit-image-text/gandhi-quote.js index d2f5a064..88be99b2 100644 --- a/commands/edit-image-text/gandhi-quote.js +++ b/commands/edit-image-text/gandhi-quote.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); @@ -55,6 +55,6 @@ module.exports = class GandhiQuoteCommand extends Command { const height = topMost + ((fontSize + 20) * i); ctx.fillText(lines[i], 395, height); } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'gandhi-quote.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'gandhi-quote.png' }] }); } }; diff --git a/commands/edit-image-text/highway-sign.js b/commands/edit-image-text/highway-sign.js index bf798cb1..85213e3b 100644 --- a/commands/edit-image-text/highway-sign.js +++ b/commands/edit-image-text/highway-sign.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); @@ -65,6 +65,6 @@ module.exports = class HighwaySignCommand extends Command { ctx.fillText(lines[2], 318, 128); ctx.fillText(lines[3], 318, 147); } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'highway-sign.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'highway-sign.png' }] }); } }; diff --git a/commands/edit-image-text/hollywood-star.js b/commands/edit-image-text/hollywood-star.js index ce4ebb87..d086104b 100644 --- a/commands/edit-image-text/hollywood-star.js +++ b/commands/edit-image-text/hollywood-star.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); module.exports = class HollywoodStarCommand extends Command { @@ -55,6 +55,6 @@ module.exports = class HollywoodStarCommand extends Command { ctx.textAlign = 'center'; ctx.textBaseline = 'top'; ctx.fillText(name.toLowerCase(), 288, 140); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'hollywood-star.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'hollywood-star.png' }] }); } }; diff --git a/commands/edit-image-text/jeopardy-question.js b/commands/edit-image-text/jeopardy-question.js index 917dee3e..d7c605a2 100644 --- a/commands/edit-image-text/jeopardy-question.js +++ b/commands/edit-image-text/jeopardy-question.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas } = require('@napi-rs/canvas'); +const { createCanvas } = require('canvas'); const { wrapText } = require('../../util/Canvas'); module.exports = class JeopardyQuestionCommand extends Command { @@ -57,6 +57,6 @@ module.exports = class JeopardyQuestionCommand extends Command { ctx.fillStyle = 'white'; ctx.fillText(lines[i], canvas.width / 2, height); } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'jeopardy-question.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'jeopardy-question.png' }] }); } }; diff --git a/commands/edit-image-text/license-plate.js b/commands/edit-image-text/license-plate.js index 42d0b6e9..957aeaa1 100644 --- a/commands/edit-image-text/license-plate.js +++ b/commands/edit-image-text/license-plate.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); module.exports = class LicensePlateCommand extends Command { @@ -48,6 +48,6 @@ module.exports = class LicensePlateCommand extends Command { ctx.textBaseline = 'middle'; ctx.font = this.client.fonts.get('LicensePlate.ttf').toCanvasString(180); ctx.fillText(text.toUpperCase(), base.width / 2, base.height / 2, 700); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'license-plate.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'license-plate.png' }] }); } }; diff --git a/commands/edit-image-text/speed-limit.js b/commands/edit-image-text/speed-limit.js index 9bdf413c..e103770f 100644 --- a/commands/edit-image-text/speed-limit.js +++ b/commands/edit-image-text/speed-limit.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); module.exports = class SpeedLimitCommand extends Command { @@ -50,6 +50,6 @@ module.exports = class SpeedLimitCommand extends Command { ctx.font = this.client.fonts.get('HWYGWDE.ttf').toCanvasString(360); ctx.fillStyle = 'black'; ctx.fillText(limit.toUpperCase(), 313, 356, 475); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'speed-limit.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'speed-limit.png' }] }); } }; diff --git a/commands/edit-image-text/spongebob-time-card.js b/commands/edit-image-text/spongebob-time-card.js index ef29f8b9..33be5700 100644 --- a/commands/edit-image-text/spongebob-time-card.js +++ b/commands/edit-image-text/spongebob-time-card.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); @@ -85,6 +85,6 @@ module.exports = class SpongebobTimeCardCommand extends Command { ctx.fillStyle = 'black'; ctx.fillText(lines[i], canvas.width / 2, height); } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'spongebob-time-card.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'spongebob-time-card.png' }] }); } }; diff --git a/commands/edit-image-text/tweet.js b/commands/edit-image-text/tweet.js index d442e8da..6b67be9c 100644 --- a/commands/edit-image-text/tweet.js +++ b/commands/edit-image-text/tweet.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const { TwitterOpenApi } = require('twitter-openapi-typescript'); const emojiRegex = require('emoji-regex'); const twemoji = require('@twemoji/parser'); @@ -202,7 +202,7 @@ module.exports = class TweetCommand extends Command { ctx.clip(); } ctx.drawImage(avatar, 17, 84, 52, 52); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'tweet.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'tweet.png' }] }); } roundedPath(ctx, radius, x, y, imageWidth, imageHeight) { diff --git a/commands/edit-image-text/undertale.js b/commands/edit-image-text/undertale.js index cabfdc9d..fb492a3c 100644 --- a/commands/edit-image-text/undertale.js +++ b/commands/edit-image-text/undertale.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); const characters = require('../../assets/json/undertale'); @@ -117,6 +117,6 @@ module.exports = class UndertaleCommand extends Command { for (let i = 0; i < lines; i++) { ctx.fillText(text[i], 174, 22 + (22 * i) + (22 * i) + (space * i)); } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: `undertale-${character}.png` }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: `undertale-${character}.png` }] }); } }; diff --git a/commands/edit-image-text/zero-dialogue.js b/commands/edit-image-text/zero-dialogue.js index 929d2a3d..5ec36ea5 100644 --- a/commands/edit-image-text/zero-dialogue.js +++ b/commands/edit-image-text/zero-dialogue.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); @@ -64,6 +64,6 @@ module.exports = class ZeroDialogueCommand extends Command { let text = wrapText(ctx, quote, 425); text = text.length > 2 ? `${text.slice(0, 2).join('\n')}...` : text.join('\n'); ctx.fillText(text, 8, 8); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'zero-dialogue.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'zero-dialogue.png' }] }); } }; diff --git a/commands/edit-image/analog-clock.js b/commands/edit-image/analog-clock.js index fb42a28f..d031ee94 100644 --- a/commands/edit-image/analog-clock.js +++ b/commands/edit-image/analog-clock.js @@ -1,5 +1,5 @@ const Command = require('../../framework/Command'); -const { createCanvas } = require('@napi-rs/canvas'); +const { createCanvas } = require('canvas'); const moment = require('moment-timezone'); const { firstUpperCase } = require('../../util/Util'); @@ -60,7 +60,7 @@ module.exports = class AnalogClockCommand extends Command { this.drawNumbers(ctx, radius); this.drawTime(ctx, radius, time); return msg.say(`${subMain || sub || main}${parens}`, { - files: [{ attachment: canvas.toBuffer('image/png'), name: 'analog-clock.png' }] + files: [{ attachment: canvas.toBuffer(), name: 'analog-clock.png' }] }); } diff --git a/commands/edit-image/approved.js b/commands/edit-image/approved.js index 035e4eaf..b0bef4d6 100644 --- a/commands/edit-image/approved.js +++ b/commands/edit-image/approved.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { centerImage } = require('../../util/Canvas'); @@ -45,7 +45,7 @@ module.exports = class ApprovedCommand extends Command { ctx.drawImage(data, 0, 0); const { x, y, width, height } = centerImage(base, data); ctx.drawImage(base, x, y, width, height); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'approved.png' }] }); } diff --git a/commands/edit-image/ascii.js b/commands/edit-image/ascii.js index ce85bad9..e62789c1 100644 --- a/commands/edit-image/ascii.js +++ b/commands/edit-image/ascii.js @@ -1,5 +1,5 @@ const Command = require('../../framework/Command'); -const { loadImage } = require('@napi-rs/canvas'); +const { loadImage } = require('canvas'); const imageToAscii = require('image-to-ascii'); const request = require('node-superfetch'); diff --git a/commands/edit-image/blur.js b/commands/edit-image/blur.js index f6bbf095..d26ef5d9 100644 --- a/commands/edit-image/blur.js +++ b/commands/edit-image/blur.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const stackBlur = require('stackblur-canvas'); @@ -40,7 +40,7 @@ module.exports = class BlurCommand extends Command { const ctx = canvas.getContext('2d'); ctx.drawImage(data, 0, 0); stackBlur.canvasRGBA(canvas, 0, 0, canvas.width, canvas.height, radius); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'blur.png' }] }); } diff --git a/commands/edit-image/bob-ross.js b/commands/edit-image/bob-ross.js index 487561df..5bcd73cf 100644 --- a/commands/edit-image/bob-ross.js +++ b/commands/edit-image/bob-ross.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { centerImagePart } = require('../../util/Canvas'); @@ -52,6 +52,6 @@ module.exports = class BobRossCommand extends Command { const { x, y, width, height } = centerImagePart(data, 440, 440, 15, 20); ctx.drawImage(data, x, y, width, height); ctx.drawImage(base, 0, 0); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'bob-ross.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'bob-ross.png' }] }); } }; diff --git a/commands/edit-image/brazzers.js b/commands/edit-image/brazzers.js index 862ad909..6e5983c7 100644 --- a/commands/edit-image/brazzers.js +++ b/commands/edit-image/brazzers.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); @@ -45,7 +45,7 @@ module.exports = class BrazzersCommand extends Command { const width = data.width / 3; const height = Math.round(width / ratio); ctx.drawImage(base, 0, data.height - height, width, height); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'brazzers.png' }] }); } diff --git a/commands/edit-image/chocolate-milk.js b/commands/edit-image/chocolate-milk.js index f6881681..4ae9fa12 100644 --- a/commands/edit-image/chocolate-milk.js +++ b/commands/edit-image/chocolate-milk.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); @@ -50,7 +50,7 @@ module.exports = class ChocolateMilkCommand extends Command { ctx.drawImage(base, 0, 0, overlay.width, height); if (direction === 'right') ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.drawImage(overlay, 0, 0); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'chocolate-milk.png' }] }); } diff --git a/commands/edit-image/circle.js b/commands/edit-image/circle.js index ccb8b006..64819b77 100644 --- a/commands/edit-image/circle.js +++ b/commands/edit-image/circle.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); module.exports = class CircleCommand extends Command { @@ -37,6 +37,6 @@ module.exports = class CircleCommand extends Command { ctx.closePath(); ctx.clip(); ctx.drawImage(data, (canvas.width / 2) - (data.width / 2), (canvas.height / 2) - (data.height / 2)); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'circle.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'circle.png' }] }); } }; diff --git a/commands/edit-image/color.js b/commands/edit-image/color.js index 044c850e..bbab80d8 100644 --- a/commands/edit-image/color.js +++ b/commands/edit-image/color.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas } = require('@napi-rs/canvas'); +const { createCanvas } = require('canvas'); const ntc = require('ntcjs'); module.exports = class ColorCommand extends Command { @@ -33,7 +33,7 @@ module.exports = class ColorCommand extends Command { ctx.fillStyle = color.toLowerCase(); ctx.fillRect(0, 0, 250, 250); return msg.say(`${color.toUpperCase()} - ${name[1]}`, { - files: [{ attachment: canvas.toBuffer('image/png'), name: 'color.png' }] + files: [{ attachment: canvas.toBuffer(), name: 'color.png' }] }); } }; diff --git a/commands/edit-image/communist.js b/commands/edit-image/communist.js index a448de68..8a84c0ba 100644 --- a/commands/edit-image/communist.js +++ b/commands/edit-image/communist.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { centerImage, drawImageWithTint } = require('../../util/Canvas'); @@ -47,7 +47,7 @@ module.exports = class CommunistCommand extends Command { ctx.globalAlpha = 0.5; ctx.drawImage(base, x + (width / 20), y + (height / 20), width * 0.9, height * 0.9); ctx.globalAlpha = 1; - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'communist.png' }] }); } diff --git a/commands/edit-image/contrast.js b/commands/edit-image/contrast.js index a7550b01..757cdf68 100644 --- a/commands/edit-image/contrast.js +++ b/commands/edit-image/contrast.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const { contrast } = require('../../util/Canvas'); @@ -33,7 +33,7 @@ module.exports = class ContrastCommand extends Command { const ctx = canvas.getContext('2d'); ctx.drawImage(data, 0, 0); contrast(ctx, 0, 0, data.width, data.height); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'contrast.png' }] }); } diff --git a/commands/edit-image/convert-image.js b/commands/edit-image/convert-image.js index 834f2c45..94a1f9e9 100644 --- a/commands/edit-image/convert-image.js +++ b/commands/edit-image/convert-image.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const formats = { jpg: 'image/jpeg', diff --git a/commands/edit-image/crop-to-content.js b/commands/edit-image/crop-to-content.js index 765ee93a..71254450 100644 --- a/commands/edit-image/crop-to-content.js +++ b/commands/edit-image/crop-to-content.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const { cropToContent } = require('../../util/Canvas'); @@ -35,7 +35,7 @@ module.exports = class CropToContentCommand extends Command { if (canvas.width === data.width && canvas.height === data.height) { return msg.say('Looks like this image is already cropped to its content.'); } - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'crop-to-content.png' }] }); } diff --git a/commands/edit-image/desaturate.js b/commands/edit-image/desaturate.js index 56f62fa9..079b403a 100644 --- a/commands/edit-image/desaturate.js +++ b/commands/edit-image/desaturate.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const { desaturate } = require('../../util/Canvas'); @@ -38,7 +38,7 @@ module.exports = class DesaturateCommand extends Command { const ctx = canvas.getContext('2d'); ctx.drawImage(data, 0, 0); desaturate(ctx, level, 0, 0, data.width, data.height); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'desaturate.png' }] }); } diff --git a/commands/edit-image/dexter.js b/commands/edit-image/dexter.js index fbe10b1d..e9b93768 100644 --- a/commands/edit-image/dexter.js +++ b/commands/edit-image/dexter.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { centerImagePart } = require('../../util/Canvas'); @@ -45,6 +45,6 @@ module.exports = class DexterCommand extends Command { const { x, y, width, height } = centerImagePart(data, 225, 225, 234, 274); ctx.drawImage(data, x, y, width, height); ctx.rotate(11 * (Math.PI / 180)); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'dexter.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'dexter.png' }] }); } }; diff --git a/commands/edit-image/distort.js b/commands/edit-image/distort.js index b4291132..1eb967ab 100644 --- a/commands/edit-image/distort.js +++ b/commands/edit-image/distort.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const { distort } = require('../../util/Canvas'); @@ -37,7 +37,7 @@ module.exports = class DistortCommand extends Command { const ctx = canvas.getContext('2d'); ctx.drawImage(data, 0, 0); distort(ctx, level, 0, 0, data.width, data.height); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'distort.png' }] }); } diff --git a/commands/edit-image/fire-frame.js b/commands/edit-image/fire-frame.js index 9a8d21fa..66af3ad3 100644 --- a/commands/edit-image/fire-frame.js +++ b/commands/edit-image/fire-frame.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { drawImageWithTint } = require('../../util/Canvas'); @@ -44,7 +44,7 @@ module.exports = class FireFrameCommand extends Command { const ctx = canvas.getContext('2d'); drawImageWithTint(ctx, data, '#fc671e', 0, 0, data.width, data.height); ctx.drawImage(base, 0, 0, data.width, data.height); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'fire-frame.png' }] }); } diff --git a/commands/edit-image/fish-eye.js b/commands/edit-image/fish-eye.js index 948c5574..40afccda 100644 --- a/commands/edit-image/fish-eye.js +++ b/commands/edit-image/fish-eye.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const { fishEye } = require('../../util/Canvas'); @@ -47,7 +47,7 @@ module.exports = class FishEyeCommand extends Command { const ctx = canvas.getContext('2d'); ctx.drawImage(data, 0, 0); fishEye(ctx, level, 0, 0, data.width, data.height); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'fish-eye.png' }] }); } diff --git a/commands/edit-image/frame.js b/commands/edit-image/frame.js index 54361d87..5e1047d7 100644 --- a/commands/edit-image/frame.js +++ b/commands/edit-image/frame.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { centerImagePart } = require('../../util/Canvas'); @@ -62,7 +62,7 @@ module.exports = class FrameCommand extends Command { ctx.drawImage(data, x, y, width, height); ctx.drawImage(base, 0, 0); } - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: `frame-${frame.file}` }] }); } diff --git a/commands/edit-image/ghost.js b/commands/edit-image/ghost.js index df196fb4..425d93b4 100644 --- a/commands/edit-image/ghost.js +++ b/commands/edit-image/ghost.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); module.exports = class GhostCommand extends Command { @@ -34,7 +34,7 @@ module.exports = class GhostCommand extends Command { ctx.fillRect(0, 0, data.width, data.height); ctx.globalAlpha = 0.25; ctx.drawImage(data, 0, 0); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'ghost.png' }] }); } diff --git a/commands/edit-image/glass-shatter.js b/commands/edit-image/glass-shatter.js index 5dac6a0a..d92d5ecc 100644 --- a/commands/edit-image/glass-shatter.js +++ b/commands/edit-image/glass-shatter.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); @@ -43,7 +43,7 @@ module.exports = class GlassShatterCommand extends Command { const ctx = canvas.getContext('2d'); ctx.drawImage(data, 0, 0); ctx.drawImage(base, 0, 0, data.width, data.height); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'glass-shatter.png' }] }); } diff --git a/commands/edit-image/glitch.js b/commands/edit-image/glitch.js index 9a7c76af..18b51a06 100644 --- a/commands/edit-image/glitch.js +++ b/commands/edit-image/glitch.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const { distort } = require('../../util/Canvas'); @@ -33,7 +33,7 @@ module.exports = class GlitchCommand extends Command { const ctx = canvas.getContext('2d'); ctx.drawImage(data, 0, 0); distort(ctx, 20, 0, 0, data.width, data.height, 5); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'glitch.png' }] }); } diff --git a/commands/edit-image/greyscale.js b/commands/edit-image/greyscale.js index 02cb0f3d..be82376e 100644 --- a/commands/edit-image/greyscale.js +++ b/commands/edit-image/greyscale.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const { greyscale } = require('../../util/Canvas'); @@ -34,7 +34,7 @@ module.exports = class GreyscaleCommand extends Command { const ctx = canvas.getContext('2d'); ctx.drawImage(data, 0, 0); greyscale(ctx, 0, 0, data.width, data.height); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'greyscale.png' }] }); } diff --git a/commands/edit-image/gun.js b/commands/edit-image/gun.js index 7969ece7..2a2ad21f 100644 --- a/commands/edit-image/gun.js +++ b/commands/edit-image/gun.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); @@ -44,7 +44,7 @@ module.exports = class GunCommand extends Command { const ratio = (data.height / 2) / base.height; const width = base.width * ratio; ctx.drawImage(base, data.width - width, data.height - (data.height / 2), width, data.height / 2); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'gun.png' }] }); } diff --git a/commands/edit-image/hands.js b/commands/edit-image/hands.js index 7345bbd6..8db3c7bc 100644 --- a/commands/edit-image/hands.js +++ b/commands/edit-image/hands.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); @@ -45,7 +45,7 @@ module.exports = class HandsCommand extends Command { const ratio = data.width / base.width; const height = base.height * ratio; ctx.drawImage(base, 0, data.height - height, data.width, height); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'hands.png' }] }); } diff --git a/commands/edit-image/ifunny.js b/commands/edit-image/ifunny.js index ddaa83ca..5db57ff4 100644 --- a/commands/edit-image/ifunny.js +++ b/commands/edit-image/ifunny.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); @@ -43,7 +43,7 @@ module.exports = class IfunnyCommand extends Command { ctx.fillStyle = '#181619'; ctx.fillRect(0, canvas.height - base.height, canvas.width, base.height); ctx.drawImage(base, canvas.width - base.width, canvas.height - base.height); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'ifunny.png' }] }); } diff --git a/commands/edit-image/invert.js b/commands/edit-image/invert.js index 5a1eac4c..a0406777 100644 --- a/commands/edit-image/invert.js +++ b/commands/edit-image/invert.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const { invert } = require('../../util/Canvas'); @@ -33,7 +33,7 @@ module.exports = class InvertCommand extends Command { const ctx = canvas.getContext('2d'); ctx.drawImage(data, 0, 0); invert(ctx, 0, 0, data.width, data.height); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'invert.png' }] }); } diff --git a/commands/edit-image/lego-icon.js b/commands/edit-image/lego-icon.js index 004cc06d..31dddfc7 100644 --- a/commands/edit-image/lego-icon.js +++ b/commands/edit-image/lego-icon.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); @@ -54,6 +54,6 @@ module.exports = class LegoIconCommand extends Command { ctx.clip(); const height = 764 / data.width; ctx.drawImage(data, (base.width / 2) - (764 / 2), (base.height / 2) - (764 / 2), 764, data.height * height); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'lego-icon.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'lego-icon.png' }] }); } }; diff --git a/commands/edit-image/mirror.js b/commands/edit-image/mirror.js index c36e38ee..ab215f6f 100644 --- a/commands/edit-image/mirror.js +++ b/commands/edit-image/mirror.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const types = ['x', 'y', 'both']; @@ -48,7 +48,7 @@ module.exports = class MirrorCommand extends Command { ctx.scale(-1, -1); } ctx.drawImage(data, 0, 0); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'mirror.png' }] }); } diff --git a/commands/edit-image/motion-blur.js b/commands/edit-image/motion-blur.js index 6060af6d..575a465e 100644 --- a/commands/edit-image/motion-blur.js +++ b/commands/edit-image/motion-blur.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const { motionBlur } = require('../../util/Canvas'); @@ -33,7 +33,7 @@ module.exports = class MotionBlurCommand extends Command { const canvas = createCanvas(data.width, data.height); const ctx = canvas.getContext('2d'); motionBlur(ctx, data, 0, 0, data.width, data.height); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'motion-blur.png' }] }); } diff --git a/commands/edit-image/needs-more-jpeg.js b/commands/edit-image/needs-more-jpeg.js index 883677bc..ac1e62e6 100644 --- a/commands/edit-image/needs-more-jpeg.js +++ b/commands/edit-image/needs-more-jpeg.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); module.exports = class NeedsMoreJpegCommand extends Command { diff --git a/commands/edit-image/pet.js b/commands/edit-image/pet.js index b99076d5..bfdb6b30 100644 --- a/commands/edit-image/pet.js +++ b/commands/edit-image/pet.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const GIFEncoder = require('gifencoder'); const request = require('node-superfetch'); const path = require('path'); diff --git a/commands/edit-image/pixelize.js b/commands/edit-image/pixelize.js index 5c1ee8b2..a761c71b 100644 --- a/commands/edit-image/pixelize.js +++ b/commands/edit-image/pixelize.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const { pixelize } = require('../../util/Canvas'); @@ -33,7 +33,7 @@ module.exports = class PixelizeCommand extends Command { const canvas = createCanvas(data.width, data.height); const ctx = canvas.getContext('2d'); pixelize(ctx, canvas, data, 0.15, 0, 0, canvas.width, canvas.height); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'pixelize.png' }] }); } diff --git a/commands/edit-image/police-tape.js b/commands/edit-image/police-tape.js index 303c0058..5d50c26a 100644 --- a/commands/edit-image/police-tape.js +++ b/commands/edit-image/police-tape.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { centerImage } = require('../../util/Canvas'); @@ -45,7 +45,7 @@ module.exports = class PoliceTapeCommand extends Command { ctx.drawImage(data, 0, 0); const { x, y, width, height } = centerImage(base, data); ctx.drawImage(base, x, y, width, height); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'police-tape.png' }] }); } diff --git a/commands/edit-image/rainbow.js b/commands/edit-image/rainbow.js index ba627eb7..63808f45 100644 --- a/commands/edit-image/rainbow.js +++ b/commands/edit-image/rainbow.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); @@ -35,7 +35,7 @@ module.exports = class RainbowCommand extends Command { const ctx = canvas.getContext('2d'); ctx.drawImage(data, 0, 0); ctx.drawImage(base, 0, 0, data.width, data.height); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'rainbow.png' }] }); } diff --git a/commands/edit-image/rejected.js b/commands/edit-image/rejected.js index 6667be58..d794a363 100644 --- a/commands/edit-image/rejected.js +++ b/commands/edit-image/rejected.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { centerImage } = require('../../util/Canvas'); @@ -45,7 +45,7 @@ module.exports = class RejctedCommand extends Command { ctx.drawImage(data, 0, 0); const { x, y, width, height } = centerImage(base, data); ctx.drawImage(base, x, y, width, height); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'rejected.png' }] }); } diff --git a/commands/edit-image/resize.js b/commands/edit-image/resize.js index a566f2b1..753bb0da 100644 --- a/commands/edit-image/resize.js +++ b/commands/edit-image/resize.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); module.exports = class ResizeCommand extends Command { @@ -43,6 +43,6 @@ module.exports = class ResizeCommand extends Command { const canvas = createCanvas(width, height); const ctx = canvas.getContext('2d'); ctx.drawImage(data, 0, 0, width, height); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'resize.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'resize.png' }] }); } }; diff --git a/commands/edit-image/rotate.js b/commands/edit-image/rotate.js index bd09b735..96c384f2 100644 --- a/commands/edit-image/rotate.js +++ b/commands/edit-image/rotate.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); module.exports = class RotateCommand extends Command { @@ -43,7 +43,7 @@ module.exports = class RotateCommand extends Command { ctx.drawImage(data, (canvas.width / 2) - (data.width / 2), (canvas.height / 2) - (data.height / 2)); ctx.translate(canvas.width / 2, canvas.height / 2); ctx.rotate(-degrees * (Math.PI / 180)); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'rotate.png' }] }); } diff --git a/commands/edit-image/sepia.js b/commands/edit-image/sepia.js index 81dc4de7..e219aab0 100644 --- a/commands/edit-image/sepia.js +++ b/commands/edit-image/sepia.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const { sepia } = require('../../util/Canvas'); @@ -33,7 +33,7 @@ module.exports = class SepiaCommand extends Command { const ctx = canvas.getContext('2d'); ctx.drawImage(data, 0, 0); sepia(ctx, 0, 0, data.width, data.height); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'sepia.png' }] }); } diff --git a/commands/edit-image/shake.js b/commands/edit-image/shake.js index 437838ab..923f1f92 100644 --- a/commands/edit-image/shake.js +++ b/commands/edit-image/shake.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const GIFEncoder = require('gifencoder'); const request = require('node-superfetch'); diff --git a/commands/edit-image/silhouette.js b/commands/edit-image/silhouette.js index 5b4cb553..cbf9de65 100644 --- a/commands/edit-image/silhouette.js +++ b/commands/edit-image/silhouette.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const { silhouette } = require('../../util/Canvas'); @@ -33,7 +33,7 @@ module.exports = class SilhouetteCommand extends Command { const ctx = canvas.getContext('2d'); ctx.drawImage(data, 0, 0); silhouette(ctx, 0, 0, data.width, data.height); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'silhouette.png' }] }); } diff --git a/commands/edit-image/sip.js b/commands/edit-image/sip.js index 75a1de67..666b97f4 100644 --- a/commands/edit-image/sip.js +++ b/commands/edit-image/sip.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); @@ -58,7 +58,7 @@ module.exports = class SipCommand extends Command { ctx.drawImage(base, 0, 0, overlay.width, height); if (direction === 'right') ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.drawImage(overlay, 0, 0); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'sip.png' }] }); } diff --git a/commands/edit-image/snapchat.js b/commands/edit-image/snapchat.js index 57e6674a..b2afa754 100644 --- a/commands/edit-image/snapchat.js +++ b/commands/edit-image/snapchat.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); module.exports = class SnapchatCommand extends Command { @@ -60,6 +60,6 @@ module.exports = class SnapchatCommand extends Command { ctx.globalAlpha = 1; ctx.fillStyle = 'white'; ctx.fillText(text, base.width / 2, barPosition - (barHeight * 0.4)); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'snapchat.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'snapchat.png' }] }); } }; diff --git a/commands/edit-image/spotify-now-playing.js b/commands/edit-image/spotify-now-playing.js index f42acaab..e7c7fcc3 100644 --- a/commands/edit-image/spotify-now-playing.js +++ b/commands/edit-image/spotify-now-playing.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); @@ -76,6 +76,6 @@ module.exports = class SpotifyNowPlayingCommand extends Command { ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(20); ctx.fillText(artist, base.width / 2, 720); ctx.fillText('Xiao\'s Picks', base.width / 2, 65); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'spotify-now-playing.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'spotify-now-playing.png' }] }); } }; diff --git a/commands/edit-image/square.js b/commands/edit-image/square.js index 8b57079e..7f84311d 100644 --- a/commands/edit-image/square.js +++ b/commands/edit-image/square.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); module.exports = class SquareCommand extends Command { @@ -32,6 +32,6 @@ module.exports = class SquareCommand extends Command { const canvas = createCanvas(dimensions, dimensions); const ctx = canvas.getContext('2d'); ctx.drawImage(data, (canvas.width / 2) - (data.width / 2), (canvas.height / 2) - (data.height / 2)); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'square.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'square.png' }] }); } }; diff --git a/commands/edit-image/steam-card.js b/commands/edit-image/steam-card.js index 5ad75431..0ff6f5f7 100644 --- a/commands/edit-image/steam-card.js +++ b/commands/edit-image/steam-card.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); @@ -68,6 +68,6 @@ module.exports = class SteamCardCommand extends Command { ctx.fillText(name, 16, 25); ctx.fillStyle = 'white'; ctx.fillText(name, 15, 24); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'steam-card.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'steam-card.png' }] }); } }; diff --git a/commands/edit-image/subtitle.js b/commands/edit-image/subtitle.js index cee4c847..b9f49baa 100644 --- a/commands/edit-image/subtitle.js +++ b/commands/edit-image/subtitle.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const { wrapText } = require('../../util/Canvas'); @@ -63,7 +63,7 @@ module.exports = class SubtitleCommand extends Command { ctx.fillStyle = 'yellow'; ctx.fillText(lines[i], base.width / 2, textHeight); } - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'subtitle.png' }] }); } diff --git a/commands/edit-image/tint.js b/commands/edit-image/tint.js index 56fc2481..168db60d 100644 --- a/commands/edit-image/tint.js +++ b/commands/edit-image/tint.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const { drawImageWithTint } = require('../../util/Canvas'); @@ -37,7 +37,7 @@ module.exports = class TintCommand extends Command { const canvas = createCanvas(data.width, data.height); const ctx = canvas.getContext('2d'); drawImageWithTint(ctx, data, color, 0, 0, data.width, data.height); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'tint.png' }] }); } diff --git a/commands/edit-image/vignette.js b/commands/edit-image/vignette.js index 52d50ec6..c87090be 100644 --- a/commands/edit-image/vignette.js +++ b/commands/edit-image/vignette.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const { vignette } = require('../../util/Canvas'); @@ -33,7 +33,7 @@ module.exports = class VignetteCommand extends Command { const ctx = canvas.getContext('2d'); ctx.drawImage(data, 0, 0); vignette(ctx, data.width, data.height); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'vignette.png' }] }); } diff --git a/commands/edit-image/wanted.js b/commands/edit-image/wanted.js index 5b484598..7fb414fa 100644 --- a/commands/edit-image/wanted.js +++ b/commands/edit-image/wanted.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { sepia, centerImagePart } = require('../../util/Canvas'); @@ -46,6 +46,6 @@ module.exports = class WantedCommand extends Command { const { x, y, width, height } = centerImagePart(data, 430, 430, 150, 360); ctx.drawImage(data, x, y, width, height); sepia(ctx, x, y, width, height); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'wanted.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'wanted.png' }] }); } }; diff --git a/commands/edit-image/wild-pokemon.js b/commands/edit-image/wild-pokemon.js index 92db05a2..0de79455 100644 --- a/commands/edit-image/wild-pokemon.js +++ b/commands/edit-image/wild-pokemon.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { centerImagePart, greyscale, pixelize } = require('../../util/Canvas'); @@ -60,6 +60,6 @@ module.exports = class WildPokemonCommand extends Command { ctx.textBaseline = 'top'; ctx.font = this.client.fonts.get('PokemonGb.ttf').toCanvasString(16); ctx.fillText(name.toUpperCase(), 106, 205, 215); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'wild-pokemon.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'wild-pokemon.png' }] }); } }; diff --git a/commands/edit-image/you-died.js b/commands/edit-image/you-died.js index a93a3c70..e98140bf 100644 --- a/commands/edit-image/you-died.js +++ b/commands/edit-image/you-died.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { centerImage, greyscale, drawImageWithTint } = require('../../util/Canvas'); @@ -45,7 +45,7 @@ module.exports = class YouDiedCommand extends Command { greyscale(ctx, 0, 0, data.width, data.height); const { x, y, width, height } = centerImage(base, data); ctx.drawImage(base, x, y, width, height); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'you-died.png' }] }); } diff --git a/commands/edit-image/yu-gi-oh-gen.js b/commands/edit-image/yu-gi-oh-gen.js index e96a6681..10e4ce63 100644 --- a/commands/edit-image/yu-gi-oh-gen.js +++ b/commands/edit-image/yu-gi-oh-gen.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { stripIndents } = require('common-tags'); @@ -145,7 +145,7 @@ module.exports = class YuGiOhGenCommand extends Command { ctx.fillStyle = monsterType === 'xyz' ? 'white' : 'black'; ctx.fillText(id.toString().padStart(8, '0'), 43, 1128); ctx.fillText(`XIAO-EN${setID.toString().padStart(3, '0')}`, 589 - (monsterType === 'link' ? 58 : 0), 849); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'yu-gi-oh-gen.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'yu-gi-oh-gen.png' }] }); } squareImage(image) { diff --git a/commands/edit-meme/3000-years.js b/commands/edit-meme/3000-years.js index e8745642..3ed29c62 100644 --- a/commands/edit-meme/3000-years.js +++ b/commands/edit-meme/3000-years.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { centerImagePart } = require('../../util/Canvas'); @@ -44,6 +44,6 @@ module.exports = class ThreeThousandYearsCommand extends Command { ctx.drawImage(base, 0, 0); const { x, y, width, height } = centerImagePart(data, 200, 200, 461, 127); ctx.drawImage(data, x, y, width, height); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: '3000-years.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: '3000-years.png' }] }); } }; diff --git a/commands/edit-meme/alert.js b/commands/edit-meme/alert.js index cdf66434..f142580f 100644 --- a/commands/edit-meme/alert.js +++ b/commands/edit-meme/alert.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); @@ -52,6 +52,6 @@ module.exports = class AlertCommand extends Command { let text = wrapText(ctx, message, 540); text = text.length > 3 ? `${text.slice(0, 3).join('\n')}...` : text.join('\n'); ctx.fillText(text, 48, 178); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'alert.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'alert.png' }] }); } }; diff --git a/commands/edit-meme/bart-chalkboard.js b/commands/edit-meme/bart-chalkboard.js index ff792b5b..c1217e23 100644 --- a/commands/edit-meme/bart-chalkboard.js +++ b/commands/edit-meme/bart-chalkboard.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { shortenText } = require('../../util/Canvas'); @@ -53,6 +53,6 @@ module.exports = class LisaPresentationCommand extends Command { const arr = []; for (let i = 0; i < 12; i++) arr.push(shortened); ctx.fillText(arr.join('\n'), 30, 27); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'bart-chalkboard.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'bart-chalkboard.png' }] }); } }; diff --git a/commands/edit-meme/be-like-bill.js b/commands/edit-meme/be-like-bill.js index 06f776ee..892dad07 100644 --- a/commands/edit-meme/be-like-bill.js +++ b/commands/edit-meme/be-like-bill.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); const texts = require('../../assets/json/be-like-bill'); @@ -51,6 +51,6 @@ module.exports = class BeLikeBillCommand extends Command { ctx.font = this.client.fonts.get('arialbd.ttf').toCanvasString(23); const text = wrapText(ctx, texts[Math.floor(Math.random() * texts.length)].replaceAll('{{name}}', name), 569); ctx.fillText(`This is ${name}.\n\n${text.join('\n')}\n\n${name} is smart.\nBe like ${name}.`, 31, 80); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'be-like-bill.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'be-like-bill.png' }] }); } }; diff --git a/commands/edit-meme/beautiful.js b/commands/edit-meme/beautiful.js index 7f3030b4..067b4e29 100644 --- a/commands/edit-meme/beautiful.js +++ b/commands/edit-meme/beautiful.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); @@ -52,6 +52,6 @@ module.exports = class BeautifulCommand extends Command { ctx.drawImage(avatar, 249, 24, 105, 105); ctx.drawImage(avatar, 249, 223, 105, 105); ctx.drawImage(base, 0, 0); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'beautiful.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'beautiful.png' }] }); } }; diff --git a/commands/edit-meme/boardroom-meeting.js b/commands/edit-meme/boardroom-meeting.js index 29e054b9..70c04013 100644 --- a/commands/edit-meme/boardroom-meeting.js +++ b/commands/edit-meme/boardroom-meeting.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); module.exports = class BoardroomMeetingCommand extends Command { @@ -70,6 +70,6 @@ module.exports = class BoardroomMeetingCommand extends Command { ctx.fillText(suggestion1, 30, 251, 90); ctx.fillText(suggestion2, 167, 258, 75); ctx.fillText(final, 310, 269, 130); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'boardroom-meeting.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'boardroom-meeting.png' }] }); } }; diff --git a/commands/edit-meme/catch.js b/commands/edit-meme/catch.js index 494ea175..48826f18 100644 --- a/commands/edit-meme/catch.js +++ b/commands/edit-meme/catch.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { delay } = require('../../util/Util'); @@ -55,6 +55,6 @@ module.exports = class CatchCommand extends Command { ctx.fillText(is.toUpperCase(), 163, 202); await msg.channel.send({ files: [path.join(__dirname, '..', '..', 'assets', 'images', 'catch', 'part-1.png')] }); await delay(time * 1000); - return msg.channel.send({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'part-2.png' }] }); + return msg.channel.send({ files: [{ attachment: canvas.toBuffer(), name: 'part-2.png' }] }); } }; diff --git a/commands/edit-meme/challenger.js b/commands/edit-meme/challenger.js index 8cc48a0b..28135c46 100644 --- a/commands/edit-meme/challenger.js +++ b/commands/edit-meme/challenger.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { silhouette, hasAlpha, centerImagePart } = require('../../util/Canvas'); @@ -120,7 +120,7 @@ module.exports = class ChallengerCommand extends Command { const img = silhouetted ? this.silhouetteImage(data) : data; const { x, y, width, height } = centerImagePart(img, gameData.maxWidth, gameData.maxHeight, gameData.x, gameData.y); ctx.drawImage(img, x, y, width, height); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'challenger.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'challenger.png' }] }); } silhouetteImage(image) { diff --git a/commands/edit-meme/change-my-mind.js b/commands/edit-meme/change-my-mind.js index 760fcebe..062172f3 100644 --- a/commands/edit-meme/change-my-mind.js +++ b/commands/edit-meme/change-my-mind.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); @@ -57,6 +57,6 @@ module.exports = class ChangeMyMindCommand extends Command { const lines = wrapText(ctx, text, 337); ctx.fillText(lines.join('\n'), 142, 430, 337); ctx.rotate(24 * (Math.PI / 180)); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'change-my-mind.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'change-my-mind.png' }] }); } }; diff --git a/commands/edit-meme/chi-idea.js b/commands/edit-meme/chi-idea.js index 4f97f51d..344b23c3 100644 --- a/commands/edit-meme/chi-idea.js +++ b/commands/edit-meme/chi-idea.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); @@ -65,6 +65,6 @@ module.exports = class ChiIdeaCommand extends Command { const height = topMost + ((fontSize + 5) * i); ctx.fillText(lines[i], 70, height); } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'chi-idea.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'chi-idea.png' }] }); } }; diff --git a/commands/edit-meme/crush.js b/commands/edit-meme/crush.js index 76b88a45..ca634990 100644 --- a/commands/edit-meme/crush.js +++ b/commands/edit-meme/crush.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { centerImagePart } = require('../../util/Canvas'); @@ -49,6 +49,6 @@ module.exports = class CrushCommand extends Command { ctx.drawImage(data, x, y, width, height); ctx.rotate(3.79 * (Math.PI / 180)); ctx.drawImage(base, 0, 0); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'crush.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'crush.png' }] }); } }; diff --git a/commands/edit-meme/cursed-sponge.js b/commands/edit-meme/cursed-sponge.js index 04d3685b..e43e5260 100644 --- a/commands/edit-meme/cursed-sponge.js +++ b/commands/edit-meme/cursed-sponge.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); module.exports = class CursedSpongeCommand extends Command { @@ -47,6 +47,6 @@ module.exports = class CursedSpongeCommand extends Command { if ((width + sponge.width) === (sponge.width * (rows > 1 ? 10 : amount))) width = 0; else width += sponge.width; } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'cursed-sponge.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'cursed-sponge.png' }] }); } }; diff --git a/commands/edit-meme/dear-liberals.js b/commands/edit-meme/dear-liberals.js index ab750593..6cd27b62 100644 --- a/commands/edit-meme/dear-liberals.js +++ b/commands/edit-meme/dear-liberals.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); @@ -73,6 +73,6 @@ module.exports = class DearLiberalsCommand extends Command { ctx.fillStyle = '#c31a41'; const redLines = wrapText(ctx, redText, 165); ctx.fillText(redLines.join('\n'), 326, 236); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'dear-liberals.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'dear-liberals.png' }] }); } }; diff --git a/commands/edit-meme/deep-fry.js b/commands/edit-meme/deep-fry.js index 0804d5a6..f70c25ca 100644 --- a/commands/edit-meme/deep-fry.js +++ b/commands/edit-meme/deep-fry.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const { desaturate, contrast } = require('../../util/Canvas'); diff --git a/commands/edit-meme/demotivational.js b/commands/edit-meme/demotivational.js index a79045a2..1f14baaf 100644 --- a/commands/edit-meme/demotivational.js +++ b/commands/edit-meme/demotivational.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const { shortenText, centerImagePart } = require('../../util/Canvas'); @@ -69,6 +69,6 @@ module.exports = class DemotivationalCommand extends Command { ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(27); ctx.fillStyle = 'white'; ctx.fillText(shortenText(ctx, text, 610), 375, 565); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'demotivational-poster.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'demotivational-poster.png' }] }); } }; diff --git a/commands/edit-meme/dislike.js b/commands/edit-meme/dislike.js index 85a81bde..a8a1ebcd 100644 --- a/commands/edit-meme/dislike.js +++ b/commands/edit-meme/dislike.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); @@ -45,7 +45,7 @@ module.exports = class DislikeCommand extends Command { const ctx = canvas.getContext('2d'); ctx.drawImage(base, 0, 0, plate.width, height); ctx.drawImage(plate, 0, height); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'dislike.png' }] }); } diff --git a/commands/edit-meme/distracted-boyfriend.js b/commands/edit-meme/distracted-boyfriend.js index 0b62ed86..4445c0a8 100644 --- a/commands/edit-meme/distracted-boyfriend.js +++ b/commands/edit-meme/distracted-boyfriend.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); @@ -64,6 +64,6 @@ module.exports = class DistractedBoyfriendCommand extends Command { ctx.drawImage(girlfriendAvatar, 539, 67, 100, 125); ctx.rotate(-3.11 * (Math.PI / 180)); ctx.drawImage(otherGirlAvatar, 120, 96, 175, 175); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'distracted-boyfriend.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'distracted-boyfriend.png' }] }); } }; diff --git a/commands/edit-meme/drakeposting.js b/commands/edit-meme/drakeposting.js index 2fe74410..699f556f 100644 --- a/commands/edit-meme/drakeposting.js +++ b/commands/edit-meme/drakeposting.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); @@ -77,6 +77,6 @@ module.exports = class DrakepostingCommand extends Command { const height = yeahTopMost + ((fontSize + 10) * i); ctx.fillText(yeahLines[i], 768, height); } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'drakeposting.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'drakeposting.png' }] }); } }; diff --git a/commands/edit-meme/edd-facts-book.js b/commands/edit-meme/edd-facts-book.js index 12cec345..d172acb8 100644 --- a/commands/edit-meme/edd-facts-book.js +++ b/commands/edit-meme/edd-facts-book.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); @@ -57,6 +57,6 @@ module.exports = class EddFactsBookCommand extends Command { const lines = wrapText(ctx, fact, 183); ctx.fillText(lines.join('\n'), 119, 306, 183); ctx.rotate(-15 * (Math.PI / 180)); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'edd-facts-book.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'edd-facts-book.png' }] }); } }; diff --git a/commands/edit-meme/enslaved.js b/commands/edit-meme/enslaved.js index a7166c02..5d19ae86 100644 --- a/commands/edit-meme/enslaved.js +++ b/commands/edit-meme/enslaved.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { centerImagePart } = require('../../util/Canvas'); @@ -55,6 +55,6 @@ module.exports = class EnslavedCommand extends Command { ctx.fillStyle = 'white'; ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(50); ctx.fillText(name.toLowerCase(), 365, 400, 240); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'enslaved.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'enslaved.png' }] }); } }; diff --git a/commands/edit-meme/food-broke.js b/commands/edit-meme/food-broke.js index 3a2c4675..f6489571 100644 --- a/commands/edit-meme/food-broke.js +++ b/commands/edit-meme/food-broke.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { contrast } = require('../../util/Canvas'); @@ -48,6 +48,6 @@ module.exports = class FoodBrokeCommand extends Command { contrast(ctx, 23, 9, 125, 125); ctx.drawImage(avatar, 117, 382, 75, 75); contrast(ctx, 117, 382, 75, 75); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'food-broke.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'food-broke.png' }] }); } }; diff --git a/commands/edit-meme/for-five-hours.js b/commands/edit-meme/for-five-hours.js index 5f0ac5f8..aec456a6 100644 --- a/commands/edit-meme/for-five-hours.js +++ b/commands/edit-meme/for-five-hours.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); @@ -45,7 +45,7 @@ module.exports = class ForFiveHoursCommand extends Command { const ctx = canvas.getContext('2d'); ctx.drawImage(base, 0, 0, plate.width, height); ctx.drawImage(plate, 0, height + 1); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'for-five-hours.png' }] }); } diff --git a/commands/edit-meme/genie-rules.js b/commands/edit-meme/genie-rules.js index 22c26348..e8f2d369 100644 --- a/commands/edit-meme/genie-rules.js +++ b/commands/edit-meme/genie-rules.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); @@ -61,6 +61,6 @@ module.exports = class GenieRulesCommand extends Command { const height = topMost + ((fontSize + 20) * i); ctx.fillText(lines[i], 220, height); } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'genie-rules.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'genie-rules.png' }] }); } }; diff --git a/commands/edit-meme/girl-worth-fighting-for.js b/commands/edit-meme/girl-worth-fighting-for.js index e764c896..1bfac588 100644 --- a/commands/edit-meme/girl-worth-fighting-for.js +++ b/commands/edit-meme/girl-worth-fighting-for.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { centerImagePart } = require('../../util/Canvas'); @@ -51,6 +51,6 @@ module.exports = class GirlWorthFightingForCommand extends Command { ctx.drawImage(base, 0, 0); const { x, y, width, height } = centerImagePart(data, 150, 150, 380, 511); ctx.drawImage(data, x, y, width, height); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'girl-worth-fighting-for.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'girl-worth-fighting-for.png' }] }); } }; diff --git a/commands/edit-meme/gru-plan.js b/commands/edit-meme/gru-plan.js index 040e3869..6a981f76 100644 --- a/commands/edit-meme/gru-plan.js +++ b/commands/edit-meme/gru-plan.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); const coord = [[450, 129], [1200, 134], [450, 627], [1200, 627]]; @@ -76,6 +76,6 @@ module.exports = class GruPlanCommand extends Command { ctx.fillText(lines.join('\n'), x, y); i++; } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'gru-plan.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'gru-plan.png' }] }); } }; diff --git a/commands/edit-meme/i-cant-believe.js b/commands/edit-meme/i-cant-believe.js index 5e8266fd..8d4eb26a 100644 --- a/commands/edit-meme/i-cant-believe.js +++ b/commands/edit-meme/i-cant-believe.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { firstUpperCase } = require('../../util/Util'); @@ -54,6 +54,6 @@ module.exports = class ICantBelieveCommand extends Command { ctx.fillStyle = '#13487b'; ctx.fillText(firstUpperCase(text.toLowerCase(), null), 13, 54, 171); ctx.rotate(8 * (Math.PI / 180)); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'i-cant-believe.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'i-cant-believe.png' }] }); } }; diff --git a/commands/edit-meme/i-fear-no-man.js b/commands/edit-meme/i-fear-no-man.js index 6abeb3df..518dee9b 100644 --- a/commands/edit-meme/i-fear-no-man.js +++ b/commands/edit-meme/i-fear-no-man.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { centerImagePart } = require('../../util/Canvas'); @@ -45,6 +45,6 @@ module.exports = class IFearNoManCommand extends Command { ctx.drawImage(base, 0, 0); const { x, y, width, height } = centerImagePart(data, 169, 169, 167, 330); ctx.drawImage(data, x, y, width, height); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'i-fear-no-man.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'i-fear-no-man.png' }] }); } }; diff --git a/commands/edit-meme/if-those-kids-could-read.js b/commands/edit-meme/if-those-kids-could-read.js index 044ec5f0..b3f88fc9 100644 --- a/commands/edit-meme/if-those-kids-could-read.js +++ b/commands/edit-meme/if-those-kids-could-read.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); @@ -59,6 +59,6 @@ module.exports = class IfThoseKidsCouldReadCommand extends Command { const height = topMost + ((fontSize + 20) * i); ctx.fillText(lines[i], 300, height); } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'if-those-kids-could-read.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'if-those-kids-could-read.png' }] }); } }; diff --git a/commands/edit-meme/kyon-gun.js b/commands/edit-meme/kyon-gun.js index 45bc3d55..11cf97cb 100644 --- a/commands/edit-meme/kyon-gun.js +++ b/commands/edit-meme/kyon-gun.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); @@ -52,6 +52,6 @@ module.exports = class KyonGunCommand extends Command { const width = Math.round(base.height * ratio); ctx.drawImage(data, (base.width / 2) - (width / 2), 0, width, base.height); ctx.drawImage(base, 0, 0); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'kyon-gun.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'kyon-gun.png' }] }); } }; diff --git a/commands/edit-meme/like.js b/commands/edit-meme/like.js index f51c7d1b..addc245d 100644 --- a/commands/edit-meme/like.js +++ b/commands/edit-meme/like.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); @@ -45,7 +45,7 @@ module.exports = class LikeCommand extends Command { const ctx = canvas.getContext('2d'); ctx.drawImage(base, 0, 0, plate.width, height); ctx.drawImage(plate, 0, height); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'like.png' }] }); } diff --git a/commands/edit-meme/lisa-presentation.js b/commands/edit-meme/lisa-presentation.js index 3f775679..738efd16 100644 --- a/commands/edit-meme/lisa-presentation.js +++ b/commands/edit-meme/lisa-presentation.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); @@ -60,6 +60,6 @@ module.exports = class LisaPresentationCommand extends Command { const height = topMost + ((fontSize + 20) * i); ctx.fillText(lines[i], base.width / 2, height); } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'lisa-presentation.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'lisa-presentation.png' }] }); } }; diff --git a/commands/edit-meme/look-at-this-photograph.js b/commands/edit-meme/look-at-this-photograph.js index 513e7ace..09078c9d 100644 --- a/commands/edit-meme/look-at-this-photograph.js +++ b/commands/edit-meme/look-at-this-photograph.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); @@ -45,6 +45,6 @@ module.exports = class LookAtThisPhotographCommand extends Command { ctx.rotate(-13.5 * (Math.PI / 180)); ctx.drawImage(data, 280, 218, 175, 125); ctx.rotate(13.5 * (Math.PI / 180)); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'look-at-this-photograph.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'look-at-this-photograph.png' }] }); } }; diff --git a/commands/edit-meme/look-what-karen-have.js b/commands/edit-meme/look-what-karen-have.js index 6d6a4f8c..1dd8710c 100644 --- a/commands/edit-meme/look-what-karen-have.js +++ b/commands/edit-meme/look-what-karen-have.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { centerImagePart } = require('../../util/Canvas'); @@ -54,6 +54,6 @@ module.exports = class LookWhatKarenHaveCommand extends Command { ctx.drawImage(data, x, y, width, height); ctx.rotate(6.5 * (Math.PI / 180)); ctx.drawImage(base, 0, 0); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'look-what-karen-have.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'look-what-karen-have.png' }] }); } }; diff --git a/commands/edit-meme/mario-bros-views.js b/commands/edit-meme/mario-bros-views.js index 949b2e22..7f55fd95 100644 --- a/commands/edit-meme/mario-bros-views.js +++ b/commands/edit-meme/mario-bros-views.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); @@ -91,6 +91,6 @@ module.exports = class MarioBrosViewsCommand extends Command { ctx.strokeText(luigiLines[i], 450, height); ctx.fillText(luigiLines[i], 450, height); } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'mario-bros-views.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'mario-bros-views.png' }] }); } }; diff --git a/commands/edit-meme/meme-gen.js b/commands/edit-meme/meme-gen.js index 6c044556..5949456d 100644 --- a/commands/edit-meme/meme-gen.js +++ b/commands/edit-meme/meme-gen.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const { wrapText } = require('../../util/Canvas'); @@ -80,7 +80,7 @@ module.exports = class MemeGenCommand extends Command { ctx.fillStyle = 'white'; ctx.fillText(bottomLines[i], base.width / 2, textHeight); } - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'meme-gen.png' }] }); } diff --git a/commands/edit-meme/metamorphosis.js b/commands/edit-meme/metamorphosis.js index 17178347..2bb56e16 100644 --- a/commands/edit-meme/metamorphosis.js +++ b/commands/edit-meme/metamorphosis.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { centerImagePart } = require('../../util/Canvas'); @@ -59,6 +59,6 @@ module.exports = class MetamorphosisCommand extends Command { ctx.textBaseline = 'top'; ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(20); ctx.fillText(`le ${name.toLowerCase()}`, 345, 466, 330); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'metamorphosis.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'metamorphosis.png' }] }); } }; diff --git a/commands/edit-meme/my-collection-grows.js b/commands/edit-meme/my-collection-grows.js index 92bdbae5..006365e4 100644 --- a/commands/edit-meme/my-collection-grows.js +++ b/commands/edit-meme/my-collection-grows.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { centerImagePart } = require('../../util/Canvas'); @@ -49,6 +49,6 @@ module.exports = class MyCollectionGrowsCommand extends Command { ctx.drawImage(data, x, y, width, height); ctx.rotate(14 * (Math.PI / 180)); ctx.drawImage(base, 0, 0); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'my-collection-grows.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'my-collection-grows.png' }] }); } }; diff --git a/commands/edit-meme/new-password.js b/commands/edit-meme/new-password.js index eefb1720..876d91ca 100644 --- a/commands/edit-meme/new-password.js +++ b/commands/edit-meme/new-password.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { shortenText } = require('../../util/Canvas'); @@ -48,6 +48,6 @@ module.exports = class NewPasswordCommand extends Command { ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(60); ctx.fillText(shortenText(ctx, weak, 780), 70, 191); ctx.fillText(shortenText(ctx, strong, 780), 70, 667); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'new-password.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'new-password.png' }] }); } }; diff --git a/commands/edit-meme/nike-ad.js b/commands/edit-meme/nike-ad.js index 8f03fd03..e5bc20a8 100644 --- a/commands/edit-meme/nike-ad.js +++ b/commands/edit-meme/nike-ad.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { wrapText, greyscale, drawImageWithTint } = require('../../util/Canvas'); @@ -74,7 +74,7 @@ module.exports = class NikeAdCommand extends Command { const textHeight = initial + (i * fontSize) + (i * 10); ctx.fillText(lines[i], data.width / 2, textHeight); } - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'nike-ad.png' }] }); } diff --git a/commands/edit-meme/panik-kalm-panik.js b/commands/edit-meme/panik-kalm-panik.js index 2b27c337..be958287 100644 --- a/commands/edit-meme/panik-kalm-panik.js +++ b/commands/edit-meme/panik-kalm-panik.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); @@ -89,6 +89,6 @@ module.exports = class PanikKalmPanikCommand extends Command { const height = panik2TopMost + ((fontSize + 10) * i); ctx.fillText(panik2Lines[i], 150, height); } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'panik-kalm-panik.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'panik-kalm-panik.png' }] }); } }; diff --git a/commands/edit-meme/phoebe-teaching-joey.js b/commands/edit-meme/phoebe-teaching-joey.js index b086a2cc..5ae72189 100644 --- a/commands/edit-meme/phoebe-teaching-joey.js +++ b/commands/edit-meme/phoebe-teaching-joey.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const coord = [ [[136, 135], [416, 135]], @@ -92,6 +92,6 @@ module.exports = class PhoebeTeachingJoeyCommand extends Command { } i++; } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'phoebe-teaching-joey.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'phoebe-teaching-joey.png' }] }); } }; diff --git a/commands/edit-meme/pills.js b/commands/edit-meme/pills.js index 9d59716b..e58492cc 100644 --- a/commands/edit-meme/pills.js +++ b/commands/edit-meme/pills.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); @@ -57,6 +57,6 @@ module.exports = class PillsCommand extends Command { ctx.strokeText(lines[i], 183, height); ctx.fillText(lines[i], 183, height); } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'pills.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'pills.png' }] }); } }; diff --git a/commands/edit-meme/plankton-plan.js b/commands/edit-meme/plankton-plan.js index cea2bdad..6cdb0b1e 100644 --- a/commands/edit-meme/plankton-plan.js +++ b/commands/edit-meme/plankton-plan.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); const coord = [[240, 63], [689, 63], [705, 383], [220, 380]]; @@ -76,6 +76,6 @@ module.exports = class PlanktonPlanCommand extends Command { ctx.fillText(lines.join('\n'), x, y); i++; } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'plankton-plan.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'plankton-plan.png' }] }); } }; diff --git a/commands/edit-meme/raw.js b/commands/edit-meme/raw.js index bcfee97c..df23e2db 100644 --- a/commands/edit-meme/raw.js +++ b/commands/edit-meme/raw.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); module.exports = class RawCommand extends Command { @@ -44,6 +44,6 @@ module.exports = class RawCommand extends Command { ctx.textBaseline = 'top'; ctx.font = this.client.fonts.get('wildwordsroman.ttf').toCanvasString(23); ctx.fillText(text, 520, 143, 165); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'raw.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'raw.png' }] }); } }; diff --git a/commands/edit-meme/reaction-meme.js b/commands/edit-meme/reaction-meme.js index 74ce1a7c..3403532a 100644 --- a/commands/edit-meme/reaction-meme.js +++ b/commands/edit-meme/reaction-meme.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const { wrapText } = require('../../util/Canvas'); @@ -60,7 +60,7 @@ module.exports = class ReactionMemeCommand extends Command { ctx.fillStyle = 'black'; ctx.fillText(lines.join('\n'), 5, 5); ctx.drawImage(base, 0, linesLen); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'meme-gen-modern.png' }] }); } diff --git a/commands/edit-meme/scroll-of-truth.js b/commands/edit-meme/scroll-of-truth.js index bfbe73a0..01e217be 100644 --- a/commands/edit-meme/scroll-of-truth.js +++ b/commands/edit-meme/scroll-of-truth.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); @@ -60,6 +60,6 @@ module.exports = class ScrollOfTruthCommand extends Command { const height = topMost + ((fontSize + 20) * i); ctx.fillText(lines[i], 350, height); } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'scroll-of-truth.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'scroll-of-truth.png' }] }); } }; diff --git a/commands/edit-meme/sexy-singles.js b/commands/edit-meme/sexy-singles.js index 76dcf555..a94c9f79 100644 --- a/commands/edit-meme/sexy-singles.js +++ b/commands/edit-meme/sexy-singles.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const count = 2; @@ -42,7 +42,7 @@ module.exports = class SexySinglesCommand extends Command { const ctx = canvas.getContext('2d'); ctx.drawImage(base, plate.width, 0, width, plate.height); ctx.drawImage(plate, 0, 0); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'sexy-singles.png' }] }); } diff --git a/commands/edit-meme/skyrim-skill.js b/commands/edit-meme/skyrim-skill.js index c6a66134..f21caf15 100644 --- a/commands/edit-meme/skyrim-skill.js +++ b/commands/edit-meme/skyrim-skill.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); @@ -64,7 +64,7 @@ module.exports = class SkyrimSkillCommand extends Command { ctx.fillText(skill, 189 + 5, height + 75 + 3, 300); ctx.fillStyle = 'white'; ctx.fillText(skill, 189, height + 75, 300); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'skyrim-skill.png' }] }); } diff --git a/commands/edit-meme/sonic-says.js b/commands/edit-meme/sonic-says.js index 2dacb6c3..a4dae94d 100644 --- a/commands/edit-meme/sonic-says.js +++ b/commands/edit-meme/sonic-says.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); @@ -56,6 +56,6 @@ module.exports = class SonicSaysCommand extends Command { const lines = wrapText(ctx, text, 185); ctx.fillStyle = 'white'; ctx.fillText(lines.join('\n'), 92, 67, 185); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'sonic-says.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'sonic-says.png' }] }); } }; diff --git a/commands/edit-meme/sora-selfie.js b/commands/edit-meme/sora-selfie.js index d2a5e5ff..751a2b22 100644 --- a/commands/edit-meme/sora-selfie.js +++ b/commands/edit-meme/sora-selfie.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); @@ -53,6 +53,6 @@ module.exports = class SoraSelfieCommand extends Command { const width = Math.round(base.height * ratio); ctx.drawImage(data, (base.width / 2) - (width / 2), 0, width, base.height); ctx.drawImage(base, 0, 0); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'sora-selfie.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'sora-selfie.png' }] }); } }; diff --git a/commands/edit-meme/sos.js b/commands/edit-meme/sos.js index 6494026d..5f9b395c 100644 --- a/commands/edit-meme/sos.js +++ b/commands/edit-meme/sos.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); module.exports = class SosCommand extends Command { @@ -56,6 +56,6 @@ module.exports = class SosCommand extends Command { } ctx.fillText(message.toUpperCase(), 362, 522); ctx.rotate(-15 * (Math.PI / 180)); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'sos.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'sos.png' }] }); } }; diff --git a/commands/edit-meme/spiderman-pointing.js b/commands/edit-meme/spiderman-pointing.js index 4681f231..ca440b3b 100644 --- a/commands/edit-meme/spiderman-pointing.js +++ b/commands/edit-meme/spiderman-pointing.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); @@ -84,6 +84,6 @@ module.exports = class SpidermanPointingCommand extends Command { ctx.strokeText(lines2[i], 596, height); ctx.fillText(lines2[i], 596, height); } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'spiderman-pointing.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'spiderman-pointing.png' }] }); } }; diff --git a/commands/edit-meme/spongebob-burn.js b/commands/edit-meme/spongebob-burn.js index 08b93e47..c487d243 100644 --- a/commands/edit-meme/spongebob-burn.js +++ b/commands/edit-meme/spongebob-burn.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); @@ -67,6 +67,6 @@ module.exports = class SpongebobBurnCommand extends Command { ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(20); ctx.fillText(person, 119, 405); ctx.fillText(person, 439, 434); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'spongebob-burn.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'spongebob-burn.png' }] }); } }; diff --git a/commands/edit-meme/that-sign-wont-stop-me.js b/commands/edit-meme/that-sign-wont-stop-me.js index 5b0639f6..669173d6 100644 --- a/commands/edit-meme/that-sign-wont-stop-me.js +++ b/commands/edit-meme/that-sign-wont-stop-me.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); @@ -72,6 +72,6 @@ module.exports = class ThatSignWontStopMeCommand extends Command { const height = bTopMost + ((fontSize + 2) * i); ctx.fillText(bLines[i], 280, height); } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'that-sign-wont-stop-me.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'that-sign-wont-stop-me.png' }] }); } }; diff --git a/commands/edit-meme/this-guy.js b/commands/edit-meme/this-guy.js index 8fa08fad..46121763 100644 --- a/commands/edit-meme/this-guy.js +++ b/commands/edit-meme/this-guy.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { centerImagePart } = require('../../util/Canvas'); @@ -45,6 +45,6 @@ module.exports = class ThisGuyCommand extends Command { ctx.drawImage(base, 0, 0); const { x, y, width, height } = centerImagePart(data, 361, 361, 76, 62); ctx.drawImage(data, x, y, width, height); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'this-guy.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'this-guy.png' }] }); } }; diff --git a/commands/edit-meme/thug-life.js b/commands/edit-meme/thug-life.js index afaf05f1..3e6134c3 100644 --- a/commands/edit-meme/thug-life.js +++ b/commands/edit-meme/thug-life.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { greyscale } = require('../../util/Canvas'); @@ -48,7 +48,7 @@ module.exports = class ThugLifeCommand extends Command { const width = data.width / 2; const height = Math.round(width / ratio); ctx.drawImage(base, (data.width / 2) - (width / 2), data.height - height, width, height); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'thug-life.png' }] }); } diff --git a/commands/edit-meme/to-be-continued.js b/commands/edit-meme/to-be-continued.js index 802aa484..4de23439 100644 --- a/commands/edit-meme/to-be-continued.js +++ b/commands/edit-meme/to-be-continued.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { drawImageWithTint } = require('../../util/Canvas'); @@ -46,7 +46,7 @@ module.exports = class ToBeContinuedCommand extends Command { const width = canvas.width / 2; const height = Math.round(width / ratio); ctx.drawImage(base, 0, canvas.height - height, width, height); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'to-be-continued.png' }] }); } diff --git a/commands/edit-meme/tuxedo-pooh.js b/commands/edit-meme/tuxedo-pooh.js index fd2140b2..8f239b6c 100644 --- a/commands/edit-meme/tuxedo-pooh.js +++ b/commands/edit-meme/tuxedo-pooh.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); @@ -77,6 +77,6 @@ module.exports = class TuxedoPoohCommand extends Command { const height = tuxedoTopMost + ((fontSize + 10) * i); ctx.fillText(tuxedoLines[i], 570, height); } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'tuxedo-pooh.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'tuxedo-pooh.png' }] }); } }; diff --git a/commands/edit-meme/two-buttons.js b/commands/edit-meme/two-buttons.js index 6110a2db..a0ba77e3 100644 --- a/commands/edit-meme/two-buttons.js +++ b/commands/edit-meme/two-buttons.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); @@ -78,6 +78,6 @@ module.exports = class TwoButtonsCommand extends Command { lineOffset += 5; } ctx.rotate(12 * (Math.PI / 180)); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'two-buttons.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'two-buttons.png' }] }); } }; diff --git a/commands/edit-meme/ugly.js b/commands/edit-meme/ugly.js index 7045a8ec..9060a643 100644 --- a/commands/edit-meme/ugly.js +++ b/commands/edit-meme/ugly.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { centerImagePart } = require('../../util/Canvas'); @@ -45,6 +45,6 @@ module.exports = class UglyCommand extends Command { const { x, y, width, height } = centerImagePart(data, 170, 170, 120, 52); ctx.drawImage(data, x, y, width, height); ctx.drawImage(base, 0, 0); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'ugly.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'ugly.png' }] }); } }; diff --git a/commands/edit-meme/ultimate-tattoo.js b/commands/edit-meme/ultimate-tattoo.js index 65439a81..2479b38c 100644 --- a/commands/edit-meme/ultimate-tattoo.js +++ b/commands/edit-meme/ultimate-tattoo.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { centerImagePart } = require('../../util/Canvas'); @@ -47,6 +47,6 @@ module.exports = class UltimateTattooCommand extends Command { const { x, y, width, height } = centerImagePart(data, 300, 300, 84, 690); ctx.drawImage(data, x, y, width, height); ctx.rotate(10 * (Math.PI / 180)); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'ultimate-tattoo.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'ultimate-tattoo.png' }] }); } }; diff --git a/commands/edit-meme/vietnam-flashbacks.js b/commands/edit-meme/vietnam-flashbacks.js index 6ff4ac2f..8ee92450 100644 --- a/commands/edit-meme/vietnam-flashbacks.js +++ b/commands/edit-meme/vietnam-flashbacks.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); @@ -45,7 +45,7 @@ module.exports = class VietnamFlashbacksCommand extends Command { ctx.drawImage(base, (data.width / 2) - (width / 2), 0, width, data.height); ctx.globalAlpha = 0.675; ctx.drawImage(data, 0, 0); - const attachment = canvas.toBuffer('image/png'); + const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'vietnam-flashbacks.png' }] }); } diff --git a/commands/edit-meme/whiteboard.js b/commands/edit-meme/whiteboard.js index e2682705..d4315367 100644 --- a/commands/edit-meme/whiteboard.js +++ b/commands/edit-meme/whiteboard.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { wrapText } = require('../../util/Canvas'); @@ -76,6 +76,6 @@ module.exports = class WhiteboardCommand extends Command { const height = resolveTopMost + ((fontSize + 10) * i); ctx.fillText(resolveLines[i], 195, height); } - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'whiteboard.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'whiteboard.png' }] }); } }; diff --git a/commands/edit-meme/worse-than-hitler.js b/commands/edit-meme/worse-than-hitler.js index 01698240..97a3125c 100644 --- a/commands/edit-meme/worse-than-hitler.js +++ b/commands/edit-meme/worse-than-hitler.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); @@ -44,6 +44,6 @@ module.exports = class WorseThanHitlerCommand extends Command { const ctx = canvas.getContext('2d'); ctx.drawImage(base, 0, 0); ctx.drawImage(avatar, 47, 42, 140, 140); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'worse-than-hitler.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'worse-than-hitler.png' }] }); } }; diff --git a/commands/edit-meme/worthless.js b/commands/edit-meme/worthless.js index 72c25514..9ffccdf7 100644 --- a/commands/edit-meme/worthless.js +++ b/commands/edit-meme/worthless.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { centerImagePart } = require('../../util/Canvas'); @@ -53,6 +53,6 @@ module.exports = class WorthlessCommand extends Command { const center2 = centerImagePart(data, 75, 75, 625, 55); ctx.drawImage(data, center2.x, center2.y, center2.width, center2.height); ctx.rotate(-160 * (Math.PI / 180)); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'worthless.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'worthless.png' }] }); } }; diff --git a/commands/games-mp/car-race.js b/commands/games-mp/car-race.js index a066c5b3..e2720138 100644 --- a/commands/games-mp/car-race.js +++ b/commands/games-mp/car-race.js @@ -1,5 +1,5 @@ const Command = require('../../framework/Command'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const { stripIndents } = require('common-tags'); const path = require('path'); @@ -551,6 +551,6 @@ module.exports = class CarRaceCommand extends Command { greyscale(ctx, bg.width - 110 - 125, 50, 125, 125); } } - return canvas.toBuffer('image/png'); + return canvas.toBuffer(); } }; diff --git a/commands/games-mp/chess.js b/commands/games-mp/chess.js index 00555802..ca932eac 100644 --- a/commands/games-mp/chess.js +++ b/commands/games-mp/chess.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const jsChess = require('js-chess-engine'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const moment = require('moment'); const validateFEN = require('fen-validator').default; const { stripIndents } = require('common-tags'); @@ -293,7 +293,7 @@ module.exports = class ChessCommand extends Command { row -= 1; } } - return canvas.toBuffer('image/png'); + return canvas.toBuffer(); } async loadImages() { diff --git a/commands/games-sp/captcha.js b/commands/games-sp/captcha.js index f0a40d21..124b3ed5 100644 --- a/commands/games-sp/captcha.js +++ b/commands/games-sp/captcha.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas } = require('@napi-rs/canvas'); +const { createCanvas } = require('canvas'); const pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ23456789'.split(''); module.exports = class CaptchaCommand extends Command { @@ -41,7 +41,7 @@ module.exports = class CaptchaCommand extends Command { ctx.strokeText(text, 15, 26); await msg.reply( '**You have 15 seconds, what does the captcha say?**', - { files: [{ attachment: canvas.toBuffer('image/png'), name: 'captcha-quiz.png' }] } + { files: [{ attachment: canvas.toBuffer(), name: 'captcha-quiz.png' }] } ); const msgs = await msg.channel.awaitMessages({ filter: res => res.author.id === msg.author.id, diff --git a/commands/games-sp/horse-race.js b/commands/games-sp/horse-race.js index 99c36a40..183f89db 100644 --- a/commands/games-sp/horse-race.js +++ b/commands/games-sp/horse-race.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const { stripIndents } = require('common-tags'); const { shuffle, randomRange, formatTime } = require('../../util/Util'); @@ -107,6 +107,6 @@ module.exports = class HorseRaceCommand extends Command { ctx.font = this.client.fonts.get('Paladins.otf').toCanvasString(15); ctx.fillText(horse.name, 251, 138 + (49 * i)); } - return { attachment: canvas.toBuffer('image/png'), name: 'leaderboard.png' }; + return { attachment: canvas.toBuffer(), name: 'leaderboard.png' }; } }; diff --git a/commands/games-sp/jeopardy.js b/commands/games-sp/jeopardy.js index 65275fca..ad266f95 100644 --- a/commands/games-sp/jeopardy.js +++ b/commands/games-sp/jeopardy.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const request = require('node-superfetch'); -const { createCanvas } = require('@napi-rs/canvas'); +const { createCanvas } = require('canvas'); const path = require('path'); const { reactIfAble } = require('../../util/Util'); const { wrapText } = require('../../util/Canvas'); @@ -88,6 +88,6 @@ module.exports = class JeopardyCommand extends Command { ctx.fillStyle = 'white'; ctx.fillText(lines[i], canvas.width / 2, height); } - return canvas.toBuffer('image/png'); + return canvas.toBuffer(); } }; diff --git a/commands/games-sp/pokemon-advantage.js b/commands/games-sp/pokemon-advantage.js index fb84a2c5..29d3038c 100644 --- a/commands/games-sp/pokemon-advantage.js +++ b/commands/games-sp/pokemon-advantage.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const { stripIndents } = require('common-tags'); const { greyscale } = require('../../util/Canvas'); @@ -147,7 +147,7 @@ module.exports = class PokemonAdvantageCommand extends Command { ctx.fillText(pokemon1.name, 128, 250, 175); ctx.strokeText(pokemon2.name, 348, 250, 175); ctx.fillText(pokemon2.name, 348, 250, 175); - return { attachment: canvas.toBuffer('image/png'), name }; + return { attachment: canvas.toBuffer(), name }; } calculateAdvantage(pkmn1, pkmn2) { diff --git a/commands/games-sp/typing-test.js b/commands/games-sp/typing-test.js index a70d948e..3527fc3e 100644 --- a/commands/games-sp/typing-test.js +++ b/commands/games-sp/typing-test.js @@ -1,5 +1,5 @@ const Command = require('../../framework/Command'); -const { createCanvas } = require('@napi-rs/canvas'); +const { createCanvas } = require('canvas'); const { stripIndents } = require('common-tags'); const Diff = require('text-diff'); const { fetchHSUserDisplay } = require('../../util/Util'); @@ -80,6 +80,6 @@ module.exports = class TypingTestCommand extends Command { ctx.fillRect(0, 0, canvas.width, canvas.height); ctx.fillStyle = 'black'; ctx.fillText(sentence, canvas.width / 2, canvas.height / 2); - return canvas.toBuffer('image/png'); + return canvas.toBuffer(); } }; diff --git a/commands/games-sp/whos-that-pokemon.js b/commands/games-sp/whos-that-pokemon.js index fec349ca..11b29038 100644 --- a/commands/games-sp/whos-that-pokemon.js +++ b/commands/games-sp/whos-that-pokemon.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const { reactIfAble } = require('../../util/Util'); const { silhouette, centerImagePart } = require('../../util/Canvas'); @@ -149,6 +149,6 @@ module.exports = class WhosThatPokemonCommand extends Command { ctx.fillStyle = '#3c5aa6'; ctx.fillText(pokemon.name, 362, 158, 240); } - return { attachment: canvas.toBuffer('image/png'), name }; + return { attachment: canvas.toBuffer(), name }; } }; diff --git a/commands/info/emoji-image.js b/commands/info/emoji-image.js index 2cdea069..e278f283 100644 --- a/commands/info/emoji-image.js +++ b/commands/info/emoji-image.js @@ -2,7 +2,7 @@ const Command = require('../../framework/Command'); const { GuildEmoji, PermissionFlagsBits } = require('discord.js'); const twemoji = require('@twemoji/parser'); const request = require('node-superfetch'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); module.exports = class EmojiImageCommand extends Command { constructor(client) { @@ -39,6 +39,6 @@ module.exports = class EmojiImageCommand extends Command { const canvas = createCanvas(512, 512); const ctx = canvas.getContext('2d'); ctx.drawImage(emojiImage, 0, 0, 512, 512); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'emoji-image.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'emoji-image.png' }] }); } }; diff --git a/commands/pokedex/pokedex-box-sprite.js b/commands/pokedex/pokedex-box-sprite.js index c3094e0f..f8ccfc7b 100644 --- a/commands/pokedex/pokedex-box-sprite.js +++ b/commands/pokedex/pokedex-box-sprite.js @@ -1,6 +1,6 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const { createCanvas } = require('@napi-rs/canvas'); +const { createCanvas } = require('canvas'); const { cropToContent } = require('../../util/Canvas'); module.exports = class PokedexBoxSpriteCommand extends Command { @@ -90,7 +90,7 @@ module.exports = class PokedexBoxSpriteCommand extends Command { const height = 30 * ratio; ctx.drawImage(this.client.pokemon.sprites, x, y, 40, 30, 0, 0, 250, height); cropToContent(ctx, canvas, canvas.width, canvas.height); - attachment = canvas.toBuffer('image/png'); + attachment = canvas.toBuffer(); } return msg.say(`#${pokemon.displayID} - ${pokemon.name}`, { files: [{ attachment, name: 'box.png' }] }); } diff --git a/commands/random-seed/friendship.js b/commands/random-seed/friendship.js index 61f25c39..5e4a67fa 100644 --- a/commands/random-seed/friendship.js +++ b/commands/random-seed/friendship.js @@ -1,7 +1,7 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); const { MersenneTwister19937, integer } = require('random-js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { percentColor } = require('../../util/Util'); @@ -90,7 +90,7 @@ module.exports = class FriendshipCommand extends Command { ctx.fillText(this.calculateLevelText(level, self, owner, authorUser, botUser), 600, 296); ctx.font = this.client.fonts.get('Pinky Cupid.otf').toCanvasString(90); ctx.fillText(level > 49 ? '👍' : '👎', 600, 100); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'friendship.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'friendship.png' }] }); } calculateLevelText(level, self, owner, authorUser, botUser) { diff --git a/commands/random-seed/ship.js b/commands/random-seed/ship.js index 72744d43..d78e2e86 100644 --- a/commands/random-seed/ship.js +++ b/commands/random-seed/ship.js @@ -1,7 +1,7 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); const { MersenneTwister19937, integer } = require('random-js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { percentColor } = require('../../util/Util'); @@ -93,7 +93,7 @@ module.exports = class ShipCommand extends Command { ctx.fillText(this.calculateLevelText(level, self, owner, authorUser, botUser), 600, 296); ctx.font = this.client.fonts.get('Pinky Cupid.otf').toCanvasString(90); ctx.fillText(level > 49 ? '❤️' : '💔', 600, 100); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'ship.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'ship.png' }] }); } calculateLevelText(level, self, owner, authorUser, botUser) { diff --git a/commands/random-seed/think-of.js b/commands/random-seed/think-of.js index 1fe0be9c..bcdf3c87 100644 --- a/commands/random-seed/think-of.js +++ b/commands/random-seed/think-of.js @@ -1,7 +1,7 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); const { MersenneTwister19937, integer } = require('random-js'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { LOVER_USER_ID } = process.env; @@ -88,6 +88,6 @@ module.exports = class ThinkOfCommand extends Command { ctx.fillText(thought.text, 600, 296); ctx.font = this.client.fonts.get('Pinky Cupid.otf').toCanvasString(90); ctx.fillText(thought.emoji, 600, 100); - return msg.say({ files: [{ attachment: canvas.toBuffer('image/png'), name: 'think-of.png' }] }); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'think-of.png' }] }); } }; diff --git a/commands/search/periodic-table.js b/commands/search/periodic-table.js index fb434329..1c2c5c9a 100644 --- a/commands/search/periodic-table.js +++ b/commands/search/periodic-table.js @@ -1,7 +1,7 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); const request = require('node-superfetch'); -const { createCanvas, loadImage } = require('@napi-rs/canvas'); +const { createCanvas, loadImage } = require('canvas'); const path = require('path'); const colors = { Solid: 'black', @@ -97,7 +97,7 @@ module.exports = class PeriodicTableCommand extends Command { const phase = element.undiscovered ? `hypothetical ${element.phase || 'element'}` : element.phase; return msg.say( `**${element.name} (${element.symbol})** is a ${phase} in ${period}.`, - { files: [{ attachment: canvas.toBuffer('image/png'), name: `${element.name}.png` }] } + { files: [{ attachment: canvas.toBuffer(), name: `${element.name}.png` }] } ); } diff --git a/package.json b/package.json index 1e8625aa..66059e7a 100644 --- a/package.json +++ b/package.json @@ -33,11 +33,11 @@ "@discordjs/opus": "^0.9.0", "@discordjs/voice": "^0.16.1", "@mediapipe/face_detection": "^0.4.1646425229", - "@napi-rs/canvas": "^0.1.52", "@tensorflow-models/face-detection": "^1.0.2", "@tensorflow/tfjs-node": "^4.18.0", "@twemoji/parser": "^15.1.1", "bombsweeper.js": "^1.0.1", + "canvas": "^2.11.2", "cheerio": "1.0.0-rc.12", "city-timezones": "^1.2.1", "cloc": "2.0.0-cloc", diff --git a/structures/fonts/Font.js b/structures/fonts/Font.js index f96994a6..a2e40b98 100644 --- a/structures/fonts/Font.js +++ b/structures/fonts/Font.js @@ -1,4 +1,4 @@ -const { GlobalFonts } = require('@napi-rs/canvas'); +const { registerFont } = require('canvas'); const weights = { 100: 'thin', 200: 'extraLight', @@ -28,7 +28,7 @@ module.exports = class Font { register() { if (this.registered) return null; this.registered = true; - return GlobalFonts.registerFromPath(this.path, this.filenameNoExt); + return registerFont(this.path, { family: this.filenameNoExt, style: this.style, weight: this.weight }); } toCanvasString(size, shouldDoFallbacks = true) { diff --git a/structures/pokemon/Pokemon.js b/structures/pokemon/Pokemon.js index df85cd99..ce631380 100644 --- a/structures/pokemon/Pokemon.js +++ b/structures/pokemon/Pokemon.js @@ -1,5 +1,5 @@ const request = require('node-superfetch'); -const { createCanvas } = require('@napi-rs/canvas'); +const { createCanvas } = require('canvas'); const path = require('path'); const { removeDuplicates, firstUpperCase, delay } = require('../../util/Util'); const { cropToContent } = require('../../util/Canvas'); @@ -159,7 +159,7 @@ module.exports = class Pokemon { const y = Math.floor(this.id / 12) * 30; ctx.drawImage(this.store.sprites, x, y, 40, 30, 0, 0, 40, 30); cropToContent(ctx, canvas, canvas.width, canvas.height); - return canvas.toBuffer('image/png'); + return canvas.toBuffer(); } async fetchSmogonTiers(...gens) { diff --git a/structures/pokemon/PokemonStore.js b/structures/pokemon/PokemonStore.js index ad6e1112..4a2190db 100644 --- a/structures/pokemon/PokemonStore.js +++ b/structures/pokemon/PokemonStore.js @@ -1,6 +1,6 @@ const { Collection } = require('@discordjs/collection'); const request = require('node-superfetch'); -const { loadImage } = require('@napi-rs/canvas'); +const { loadImage } = require('canvas'); const path = require('path'); const Pokemon = require('./Pokemon'); const MoveStore = require('./MoveStore'); diff --git a/util/Canvas.js b/util/Canvas.js index 12e6f561..879c540f 100644 --- a/util/Canvas.js +++ b/util/Canvas.js @@ -1,4 +1,4 @@ -const { createCanvas } = require('@napi-rs/canvas'); +const { createCanvas } = require('canvas'); module.exports = class CanvasUtil { static greyscale(ctx, x, y, width, height) {