Spaghetti Command Returns!

This commit is contained in:
Dragon Fire
2024-05-09 14:33:39 -04:00
parent 632474620a
commit f102b72b24
21 changed files with 46 additions and 3 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 142 KiB

+43
View File
@@ -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' }] });
}
};
+1 -1
View File
@@ -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