mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Spaghetti Command Returns!
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 142 KiB |
@@ -0,0 +1,43 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { PermissionFlagsBits } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
const { readFile } = require('fs/promises');
|
||||
const path = require('path');
|
||||
const { reactIfAble } = require('../../util/Util');
|
||||
const { LOADING_EMOJI_ID, SUCCESS_EMOJI_ID } = process.env;
|
||||
|
||||
module.exports = class SpaghettiCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'spaghetti',
|
||||
aliases: ['spaghet', 'pasta', 'spaghettify'],
|
||||
group: 'edit-image',
|
||||
memberName: 'spaghetti',
|
||||
description: 'Draws an image or a user\'s avatar but as spaghetti.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 120
|
||||
},
|
||||
clientPermissions: [PermissionFlagsBits.AttachFiles],
|
||||
args: [
|
||||
{
|
||||
key: 'image',
|
||||
type: 'image-or-avatar',
|
||||
maxAttachmentSize: 2e+6,
|
||||
avatarSize: 512,
|
||||
default: msg => msg.author.displayAvatarURL({ extension: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { image }) {
|
||||
const { body } = await request.get(image);
|
||||
const style = await readFile(path.join(__dirname, '..', '..', 'assets', 'images', 'spaghetti.jpg'));
|
||||
await reactIfAble(msg, msg.author, LOADING_EMOJI_ID, '💬');
|
||||
const attachment = await this.client.tensorflow.stylizeImage(body, style);
|
||||
await reactIfAble(msg, msg.author, SUCCESS_EMOJI_ID, '✅');
|
||||
if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'spaghetti.jpg' }] });
|
||||
}
|
||||
};
|
||||
@@ -37,7 +37,7 @@ module.exports = class Tensorflow {
|
||||
|
||||
async loadTransformerModel() {
|
||||
const model = await tf.loadGraphModel(
|
||||
url.pathToFileURL(path.join(__dirname, '..', 'tf_models', 'transformer_separable_js', 'model.json')).href
|
||||
url.pathToFileURL(path.join(__dirname, '..', 'tf_models', 'transformer_js', 'model.json')).href
|
||||
);
|
||||
this.transformerModel = model;
|
||||
return this.transformerModel;
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user