Commands updated

This commit is contained in:
Atridad Lahiji 2023-12-03 16:05:43 -07:00
parent 43b7b3fd2e
commit 2d0e8ab106
No known key found for this signature in database

View file

@ -1,6 +1,6 @@
import { ApplyOptions } from '@sapphire/decorators';
import { Args, BucketScope, Command } from '@sapphire/framework';
import { Message } from 'discord.js';
import { AttachmentBuilder, Message } from 'discord.js';
import Replicate from 'replicate';
const replicate = new Replicate({
@ -49,13 +49,17 @@ export class UserCommand extends Command {
let result = (await replicate.run('stability-ai/sdxl:39ed52f2a78e934b3ba6e2a89f5b1c712de7dfea535525255b1aa35c5565e08b', {
input: {
width: 1024,
height: 1024,
prompt,
disable_safety_checker: true,
refine: 'expert_ensemble_refiner',
num_inference_steps: 50,
scheduler: 'K_EULER',
width: 1024,
height: 1024
scheduler: 'KarrasDPM',
num_outputs: 1,
guidance_scale: 7.5,
high_noise_frac: 0.8,
prompt_strength: 0.8,
num_inference_steps: 50
}
})) as string[];
@ -70,14 +74,28 @@ export class UserCommand extends Command {
content: content
});
} else {
const content = `Prompt: ${prompt}\n URL: ${result[0]}`;
const imageUrl = result[0] || '';
// get an array buffer
const imageBuffer = await fetch(imageUrl).then((r) => r.arrayBuffer());
const imageAttachment: AttachmentBuilder[] = [];
imageAttachment.push(
new AttachmentBuilder(Buffer.from(new Uint8Array(imageBuffer)), {
name: 'himbot_response.jpg',
description: `An image generated by Himbot using the prompt: ${prompt}`
})
);
const content = `Prompt: ${prompt}`;
if (interactionOrMessage instanceof Message) {
return askMessage.edit({ content });
return askMessage.edit({ content, files: imageAttachment });
}
return interactionOrMessage.editReply({
content
content,
files: imageAttachment
});
}
}