diff --git a/README.md b/README.md index 65a62569..b3f6feec 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Xiao is a Discord bot coded in JavaScript with 6. Run `npm i -g pm2` to install PM2. 7. Run `pm2 start Xiao.js --name xiao` to run the bot. -## Commands (343) +## Commands (344) ### Utility: * **eval:** Executes JavaScript code. @@ -291,6 +291,7 @@ Xiao is a Discord bot coded in JavaScript with * **color:** Sends an image of the color you choose. * **contrast:** Draws an image or a user's avatar but with contrast. * **create-qr-code:** Converts text to a QR Code. +* **cursed-sponge:** Sends a cursed sponge duplicated however many times you want. * **demotivational:** Draws an image or a user's avatar and the text you specify as a demotivational poster. * **distort:** Draws an image or a user's avatar but distorted. * **fire:** Draws a fiery border over an image or a user's avatar. diff --git a/assets/images/cursed-sponge.png b/assets/images/cursed-sponge.png new file mode 100644 index 00000000..c6ca40c1 Binary files /dev/null and b/assets/images/cursed-sponge.png differ diff --git a/commands/image-edit/cursed-sponge.js b/commands/image-edit/cursed-sponge.js new file mode 100644 index 00000000..f7addb75 --- /dev/null +++ b/commands/image-edit/cursed-sponge.js @@ -0,0 +1,44 @@ +const Command = require('../../structures/Command'); +const { createCanvas, loadImage } = require('canvas'); +const path = require('path'); + +module.exports = class CursedSpongeCommand extends Command { + constructor(client) { + super(client, { + name: 'cursed-sponge', + aliases: ['sponge-snail'], + group: 'image-edit', + memberName: 'cursed-sponge', + description: 'Sends a cursed sponge duplicated however many times you want.', + throttling: { + usages: 1, + duration: 30 + }, + clientPermissions: ['ATTACH_FILES'], + args: [ + { + key: 'amount', + prompt: 'How many times do you want to duplicate the cursed sponge?', + type: 'integer', + max: 100 + } + ] + }); + } + + async run(msg, { amount }) { + const sponge = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'cursed-sponge.png')); + const rows = Math.ceil(10 / amount); + const canvas = createCanvas(sponge.width * (rows > 1 ? 10 : amount), sponge.height * rows); + const ctx = canvas.getContext('2d'); + let width = 0; + for (let i = 0; i < amount; i++) { + const row = Math.ceil((i + 1) / 10); + ctx.drawImage(sponge, width, sponge.height * row); + if ((width + sponge.width) === (sponge.width * (rows > 1 ? 10 : amount))) width = 0; + else width += sponge.width; + } + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'cursed-sponge.png' }] }); + } +}; + diff --git a/package.json b/package.json index 46ec257d..ef5d37a1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "107.2.0", + "version": "107.3.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {