mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-06 22:44:32 +02:00
Communist Command
This commit is contained in:
@@ -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/)
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 153 KiB |
@@ -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!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "116.24.1",
|
||||
"version": "116.25.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user