diff --git a/README.md b/README.md index 773cb8d3..47d72178 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ Xiao is a Discord bot coded in JavaScript with * [Storyteller](https://github.com/dragonfire535/storyteller) is a Mafia bot made for Discord's 2019 Hack Week, whose features were originally built into Xiao. * [Meme Poster](https://github.com/dragonfire535/meme-poster) is a meme-posting webhook, inspired by an idea that started as part of Xiao. -## Commands (346) +## Commands (347) ### Utility: * **eval:** Executes JavaScript code. @@ -327,6 +327,7 @@ Xiao is a Discord bot coded in JavaScript with * **shields-io-badge:** Creates a badge from shields.io. * **silhouette:** Draws a silhouette of an image or a user's avatar. * **sora-selfie:** Draws an image or a user's avatar behind Sora taking a selfie. +* **spongebob-burn:** Sends a "Spongebob Throwing Something into a Fire" meme with words of your choice. * **square:** Draws an image or a user's avatar as a square. * **thug-life:** Draws "Thug Life" over an image or a user's avatar. * **tint:** Draws an image or a user's avatar but tinted a specific color. diff --git a/assets/images/spongebob-burn.png b/assets/images/spongebob-burn.png new file mode 100644 index 00000000..aa1e4a73 Binary files /dev/null and b/assets/images/spongebob-burn.png differ diff --git a/commands/image-edit/spongebob-burn.js b/commands/image-edit/spongebob-burn.js new file mode 100644 index 00000000..10f3a4df --- /dev/null +++ b/commands/image-edit/spongebob-burn.js @@ -0,0 +1,72 @@ +const Command = require('../../structures/Command'); +const { createCanvas, loadImage, registerFont } = require('canvas'); +const path = require('path'); +const { wrapText } = require('../../util/Canvas'); +registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Regular.ttf'), { family: 'Noto' }); +registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-CJK.otf'), { family: 'Noto' }); +registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Emoji.ttf'), { family: 'Noto' }); + +module.exports = class SpongebobBurnCommand extends Command { + constructor(client) { + super(client, { + name: 'spongebob-burn', + aliases: ['sponge-burn', 'spongebob-fire', 'sponge-fire'], + group: 'image-edit', + memberName: 'spongebob-burn', + description: 'Sends a "Spongebob Throwing Something into a Fire" meme with words of your choice.', + throttling: { + usages: 1, + duration: 10 + }, + clientPermissions: ['ATTACH_FILES'], + credit: [ + { + name: 'Spongebob', + url: 'https://www.nick.com/shows/spongebob-squarepants' + }, + { + name: 'Google Noto Fonts', + url: 'https://www.google.com/get/noto/' + } + ], + args: [ + { + key: 'burn', + label: 'thing to burn', + prompt: 'What should Spongebob burn?', + type: 'string', + max: 150 + }, + { + key: 'person', + prompt: 'What should Spongebob be labelled as?', + type: 'string', + max: 15 + } + ] + }); + } + + async run(msg, { burn, person }) { + const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'spongebob-burn.png')); + const canvas = createCanvas(base.width, base.height); + const ctx = canvas.getContext('2d'); + ctx.drawImage(base, 0, 0); + ctx.fillStyle = 'black'; + ctx.textBaseline = 'top'; + ctx.font = '35px Noto'; + let fontSize = 35; + while (ctx.measureText(burn).width > 360) { + fontSize -= 1; + ctx.font = `${fontSize}px Noto`; + } + const lines = await wrapText(ctx, burn, 180); + ctx.fillText(lines.join('\n'), 50, 83); + ctx.font = '25px Noto'; + ctx.fillText(person, 382, 26); + ctx.font = '20px Noto'; + ctx.fillText(person, 114, 405); + ctx.fillText(person, 434, 434); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'spongebob-burn.png' }] }); + } +}; diff --git a/package.json b/package.json index bf53cb35..cd4dc676 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "107.5.0", + "version": "107.6.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {