diff --git a/README.md b/README.md index aaba4358..9cd4ee99 100644 --- a/README.md +++ b/README.md @@ -227,7 +227,7 @@ in the appropriate channel's topic to use it. ## Commands -Total: 484 +Total: 485 ### Utility: @@ -558,6 +558,7 @@ Total: 484 * **chinese-restaurant:** Sends a Chinese restaurant sign with the text of your choice. * **circle:** Draws an image or a user's avatar as a circle. * **color:** Sends an image of the color you choose. +* **communist:** Draws the Communist flag over an image or a user's avatar. * **contrast:** Draws an image or a user's avatar but with contrast. * **convert-image:** Converts an image or user's avatar from one format to another. * **create-qr-code:** Converts text to a QR Code. @@ -1303,6 +1304,8 @@ here. * guesspionage ([Question Data](https://www.playstationtrophies.org/game/the-jackbox-party-pack-3/trophy/157520-Guesspionage--Perfect-Surveillance.html)) - [PNG Arts](https://www.pngarts.com/) * police-tape ([Image](https://www.pngarts.com/explore/94078)) +- [PNGFuel](https://www.pngfuel.com/) + * communist ([Image](https://www.pngfuel.com/free-png/osnol)) - [pngimg.com](https://pngimg.com/) * thug-life ([Image](http://pngimg.com/download/58231)) - [Pokemon Fusion](https://pokemon.alexonsager.net/) diff --git a/assets/images/communist.png b/assets/images/communist.png new file mode 100644 index 00000000..c27fedaa Binary files /dev/null and b/assets/images/communist.png differ diff --git a/commands/edit-image/communist.js b/commands/edit-image/communist.js new file mode 100644 index 00000000..471d20b3 --- /dev/null +++ b/commands/edit-image/communist.js @@ -0,0 +1,58 @@ +const Command = require('../../structures/Command'); +const { createCanvas, loadImage } = require('canvas'); +const request = require('node-superfetch'); +const path = require('path'); +const { centerImage, drawImageWithTint } = require('../../util/Canvas'); + +module.exports = class CommunistCommand extends Command { + constructor(client) { + super(client, { + name: 'communist', + aliases: ['commie', 'communism'], + group: 'edit-image', + memberName: 'communist', + description: 'Draws the Communist flag over an image or a user\'s avatar.', + throttling: { + usages: 1, + duration: 10 + }, + clientPermissions: ['ATTACH_FILES'], + credit: [ + { + name: 'PNGFuel', + url: 'https://www.pngfuel.com/', + reason: 'Image', + reasonURL: 'https://www.pngfuel.com/free-png/osnol' + } + ], + args: [ + { + key: 'image', + prompt: 'What image would you like to edit?', + type: 'image', + default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 }) + } + ] + }); + } + + async run(msg, { image }) { + try { + const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'communist.png')); + const { body } = await request.get(image); + const data = await loadImage(body); + const canvas = createCanvas(data.width, data.height); + const ctx = canvas.getContext('2d'); + drawImageWithTint(ctx, data, 'red', 0, 0, data.width, data.height); + const { x, y, width, height } = centerImage(base, data); + ctx.globalAlpha = 0.5; + ctx.drawImage(base, x, y, width, height); + ctx.globalAlpha = 1; + 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' }] }); + } catch (err) { + return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } + } +}; diff --git a/package.json b/package.json index 200535fe..05e0b807 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "116.24.1", + "version": "116.25.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {