This commit is contained in:
Atridad Lahiji 2023-11-10 23:52:39 -07:00
parent 704ff9fc2a
commit a58eb676bd
No known key found for this signature in database
4 changed files with 49 additions and 62 deletions

View file

@ -59,37 +59,25 @@ export class UserCommand extends Command {
// get an array buffer
const imageBuffer = await fetch(imageUrl).then((r) => r.arrayBuffer());
if (response.data.length === 0) {
const content = `Sorry, I can't complete the prompt for: ${prompt}`;
const imageAttachment: AttachmentBuilder[] = [];
if (interactionOrMessage instanceof Message) {
return askMessage.edit({ content });
}
imageAttachment.push(
new AttachmentBuilder(Buffer.from(new Uint8Array(imageBuffer)), {
name: 'himbot_response.jpg',
description: `An image generated by Himbot using the prompt: ${prompt}`
})
);
return interactionOrMessage.editReply({
content: content
});
} else {
const imageAttachment: AttachmentBuilder[] = [];
const content = `Prompt: ${prompt}:`;
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, files: imageAttachment });
}
return interactionOrMessage.editReply({
content,
files: imageAttachment
});
if (interactionOrMessage instanceof Message) {
return askMessage.edit({ content, files: imageAttachment });
}
return interactionOrMessage.editReply({
content,
files: imageAttachment
});
} catch (error) {
const content = "Sorry, I can't complete the prompt for: " + prompt + '\n' + error;

View file

@ -59,37 +59,25 @@ export class UserCommand extends Command {
// get an array buffer
const imageBuffer = await fetch(imageUrl).then((r) => r.arrayBuffer());
if (response.data.length === 0) {
const content = `Sorry, I can't complete the prompt for: ${prompt}`;
const imageAttachment: AttachmentBuilder[] = [];
if (interactionOrMessage instanceof Message) {
return askMessage.edit({ content });
}
imageAttachment.push(
new AttachmentBuilder(Buffer.from(new Uint8Array(imageBuffer)), {
name: 'himbot_response.jpg',
description: `An image generated by Himbot using the prompt: ${prompt}`
})
);
return interactionOrMessage.editReply({
content: content
});
} else {
const imageAttachment: AttachmentBuilder[] = [];
const content = `Prompt: ${prompt}:`;
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, files: imageAttachment });
}
return interactionOrMessage.editReply({
content,
files: imageAttachment
});
if (interactionOrMessage instanceof Message) {
return askMessage.edit({ content, files: imageAttachment });
}
return interactionOrMessage.editReply({
content,
files: imageAttachment
});
} catch (error) {
const content = "Sorry, I can't complete the prompt for: " + prompt + '\n' + error;

View file

@ -1,6 +1,6 @@
import { ApplyOptions } from '@sapphire/decorators';
import { Args, BucketScope, Command } from '@sapphire/framework';
import { AttachmentBuilder, Message } from 'discord.js';
import { AttachmentBuilder, Message, MessageFlags } from 'discord.js';
import OpenAI from 'openai';
const openai = new OpenAI({
@ -64,21 +64,32 @@ export class UserCommand extends Command {
const content = `Prompt: ${prompt}:`;
if (interactionOrMessage instanceof Message) {
return askMessage.edit({ content, files: mp3Attachment });
return askMessage.edit({
content,
files: mp3Attachment,
flags: '8192'
});
}
return interactionOrMessage.editReply({
content,
files: mp3Attachment
files: mp3Attachment,
options: {
flags: MessageFlags.IsVoiceMessage.valueOf()
}
});
} catch (error) {
const content = "Sorry, I can't complete the prompt for: " + prompt + '\n' + error;
if (interactionOrMessage instanceof Message) {
return askMessage.edit({ content });
return askMessage.edit({
content
});
}
return interactionOrMessage.editReply({ content });
return interactionOrMessage.editReply({
content
});
}
}
}

View file

@ -8,8 +8,8 @@ const client = new SapphireClient({
status: 'online',
activities: [
{
name: 'BOAT PARADE! BOAT PARADE! BOAT PARADE!',
type: ActivityType.Listening
name: 'idk',
type: ActivityType.Custom
}
]
},
@ -22,7 +22,7 @@ const client = new SapphireClient({
defaultCooldown: {
// 10s
delay: 10_000,
filteredCommands: ['disclosure', 'support', 'ping', 'wryna'],
filteredCommands: ['support', 'ping', 'wryna'],
limit: 2,
// Yes... I did hardcode myself.
filteredUsers: ['83679718401904640'],