From 2c75ff09d95a054dad8af67767be2c04fc2ff9b9 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Mon, 29 May 2023 09:22:11 -0400 Subject: [PATCH] Improved embed style. --- functions.js | 24 +++++++++++++++++++----- slash-commands/chat.js | 4 ++-- slash-commands/dalle.js | 2 +- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/functions.js b/functions.js index 6296e14..2547257 100644 --- a/functions.js +++ b/functions.js @@ -377,13 +377,27 @@ const functions = { interaction.reply({ embeds: [ strainEmbed ]}); }, - dalle(prompt, imageUrl) { + dalle(user, prompt, imageUrl) { const dalleEmbed = new Discord.MessageEmbed() - .setAuthor({ name: "NodDraw" }) - .setTimestamp() + .setAuthor({ name: "NodBot powered by DALL-E", iconURL: "https://assets.vfsh.dev/openai-logos/PNGs/openai-logomark.png" }) + .addFields( + { name: "Prompt", value: prompt } + ) .setImage(imageUrl) - .setFooter({ text: prompt }); + .setFooter({ text: user.username, iconURL: user.avatarURL() }) + .setTimestamp(); return { embeds: [dalleEmbed] }; + }, + gpt(user, prompt, response) { + const gptEmbed = new Discord.MessageEmbed() + .setAuthor({ name: "NodBot powered by GPT-3", iconURL: "https://assets.vfsh.dev/openai-logos/PNGs/openai-logomark.png" }) + .addFields( + { name: "Prompt", value: prompt }, + { name: "Response", value: response } + ) + .setFooter({ text: user.username, iconURL: user.avatarURL() }) + .setTimestamp(); + return { embeds: [gptEmbed] }; } }, collect: { @@ -566,7 +580,7 @@ const functions = { reject(e); return null; }); - resolve(response); + resolve(response.data.choices[0].text); }); }, imagePrompt(userPrompt, size, userId) { diff --git a/slash-commands/chat.js b/slash-commands/chat.js index 848efe8..e3aee29 100644 --- a/slash-commands/chat.js +++ b/slash-commands/chat.js @@ -14,7 +14,7 @@ module.exports = { await interaction.deferReply(); const userPrompt = interaction.options.getString("prompt"); const response = await fn.openAI.chatPrompt(userPrompt).catch(e => console.error(e)); - const responseText = response.data.choices[0].text; - await interaction.editReply(`${responseText}`); + const gptEmbed = fn.embeds.gpt(interaction.user, userPrompt, response); + await interaction.editReply(gptEmbed); }, }; \ No newline at end of file diff --git a/slash-commands/dalle.js b/slash-commands/dalle.js index ccb1ad6..ff105f6 100644 --- a/slash-commands/dalle.js +++ b/slash-commands/dalle.js @@ -26,7 +26,7 @@ module.exports = { const size = interaction.options.getString("size") ? interaction.options.getString("size") : "512x512"; const imageUrl = await fn.openAI.imagePrompt(userPrompt, size); - const dalleEmbed = fn.embeds.dalle(userPrompt, imageUrl); + const dalleEmbed = fn.embeds.dalle(interaction.user, userPrompt, imageUrl); await interaction.editReply(dalleEmbed); } catch (err) { const errorId = fn.generateErrorId();