Deep Fry Command

This commit is contained in:
Dragon Fire
2020-06-13 19:15:33 -04:00
parent fe6c793868
commit 48dab01d86
3 changed files with 48 additions and 2 deletions
+2 -1
View File
@@ -227,7 +227,7 @@ in the appropriate channel's topic to use it.
## Commands
Total: 483
Total: 484
### Utility:
@@ -636,6 +636,7 @@ Total: 483
* **chi-idea:** Sends a "Daddy, I've got an idea!" Takagi-san meme with the text of your choice.
* **cursed-sponge:** Sends a cursed sponge duplicated however many times you want.
* **dear-liberals:** Sends a "Dear Liberals" meme with words of your choice.
* **deep-fry:** Draws an image or a user's avatar but deep-fried.
* **demotivational:** Draws an image or a user's avatar and the text you specify as a demotivational poster.
* **dislike:** Sends an "Everyone Disliked That" meme with the image of your choice.
* **distracted-boyfriend:** Draws three user's avatars over the "Distracted Boyfriend" meme.
+45
View File
@@ -0,0 +1,45 @@
const Command = require('../../structures/Command');
const { createCanvas, loadImage } = require('canvas');
const request = require('node-superfetch');
const { desaturate, contrast } = require('../../util/Canvas');
module.exports = class DeepFryCommand extends Command {
constructor(client) {
super(client, {
name: 'deep-fry',
group: 'edit-meme',
memberName: 'deep-fry',
description: 'Draws an image or a user\'s avatar but deep-fried.',
throttling: {
usages: 1,
duration: 10
},
clientPermissions: ['ATTACH_FILES'],
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 { body } = await request.get(image);
const data = await loadImage(body);
const canvas = createCanvas(data.width, data.height);
const ctx = canvas.getContext('2d');
ctx.drawImage(data, 0, 0);
desaturate(ctx, -20, 0, 0, data.width, data.height);
contrast(ctx, 0, 0, data.width, data.height);
const attachment = canvas.toBuffer('image/jpeg', { quality: 0.5 });
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
return msg.say({ files: [{ attachment, name: 'deep-fry.jpeg' }] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "116.23.0",
"version": "116.24.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {