mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:26:21 +02:00
40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
const Command = require('../../framework/Command');
|
|
const { PermissionFlagsBits } = require('discord.js');
|
|
const gm = require('gm').subClass({ imageMagick: '7+' });
|
|
const request = require('node-superfetch');
|
|
const { magikToBuffer } = require('../../util/Util');
|
|
|
|
module.exports = class OilPaintingCommand extends Command {
|
|
constructor(client) {
|
|
super(client, {
|
|
name: 'oil-painting',
|
|
aliases: ['oil', 'paint', 'painting'],
|
|
group: 'edit-image',
|
|
description: 'Draws an image or a user\'s avatar but with oil paints.',
|
|
throttling: {
|
|
usages: 2,
|
|
duration: 15
|
|
},
|
|
clientPermissions: [PermissionFlagsBits.AttachFiles],
|
|
args: [
|
|
{
|
|
key: 'image',
|
|
type: 'image-or-avatar',
|
|
avatarSize: 512,
|
|
default: msg => msg.author.displayAvatarURL({ extension: 'png', size: 512, forceStatic: true })
|
|
}
|
|
]
|
|
});
|
|
}
|
|
|
|
async run(msg, { image }) {
|
|
const { body } = await request.get(image);
|
|
const magik = gm(body);
|
|
magik.paint(5);
|
|
magik.setFormat('png');
|
|
const attachment = await magikToBuffer(magik);
|
|
if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.');
|
|
return msg.say({ files: [{ attachment, name: 'old-painting.png' }] });
|
|
}
|
|
};
|