From e301c720da2da0043085b35e739a841ed98916b6 Mon Sep 17 00:00:00 2001 From: oelin <42823429+oelin@users.noreply.github.com> Date: Mon, 30 Jan 2023 12:20:44 +0000 Subject: [PATCH] Create imagine.js --- commands/imagine.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 commands/imagine.js diff --git a/commands/imagine.js b/commands/imagine.js new file mode 100644 index 0000000..baea770 --- /dev/null +++ b/commands/imagine.js @@ -0,0 +1,31 @@ +const { SlashCommandBuilder } = require('discord.js') + + +module.exports = { + data: new SlashCommandBuilder() + .setName('imagine') + .setDescription('There are endless possibilities...') + .addStringOption(option => + option + .setName('prompt') + .setDescription('The prompt to imagine') + .setRequired(true) + ), + async execute(interaction) { + + const { default: midjourney } = await import('midjourney-client') + const prompt = interaction.options.getString('prompt') + + midjourney(prompt).then(response => { + if (response.length < 1) { + interaction.editReply('Unabled to generate images 😭.') + } + + const imageURLs = response.join('\n') + interaction.editReply(`**${prompt}**\n${imageURLs}`) + + }) + + await interaction.reply('Generating images, may take up to 7 seconds...') + } +}