nodbot/slash-commands/dalle.js

25 lines
789 B
JavaScript
Raw Normal View History

2023-05-28 14:08:51 +00:00
const { SlashCommandBuilder } = require('@discordjs/builders');
const fn = require('../functions.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('dalle')
.setDescription('Generate an image with DALL-e')
.addStringOption(o =>
o.setName("prompt")
.setDescription("Prompt to send to DALL-e")
.setRequired(true)
),
async execute(interaction) {
try {
await interaction.deferReply();
const userPrompt = interaction.options.getString("prompt");
const response = await fn.openAI.imagePrompt(userPrompt);
await interaction.editReply(`${response}`);
} catch (err) {
const errorId = fn.generateErrorId();
console.error(`${errorId}: ${err}`);
await interaction.editReply(`An error has occured. Error ID: ${errorId}\n${err}`);
}
},
};