From 5fbf3220347ac293e096e7666cb76b01b0761ad7 Mon Sep 17 00:00:00 2001 From: Andy W Date: Wed, 14 Aug 2024 18:33:45 -0400 Subject: [PATCH] fixed inconsistent hf token naming bug --- docker-compose.yaml | 2 +- fly.toml | 2 +- src/commands/utility/sticker.js | 162 ++++++++++++++++---------------- 3 files changed, 82 insertions(+), 84 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index a5dd707..6afdb3a 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -12,7 +12,7 @@ services: DISCORD_TOKEN: ${DISCORD_TOKEN} PUBLIC_KEY: ${PUBLIC_KEY} HF_TOKEN: ${HF_TOKEN} - HUGGINGFACE_ENDPOINT: ${HUGGINGFACE_ENDPOINT} + HF_ENDPOINT: ${HF_ENDPOINT} env_file: - .env diff --git a/fly.toml b/fly.toml index a5930f9..501b0c8 100644 --- a/fly.toml +++ b/fly.toml @@ -1,4 +1,4 @@ -# fly.toml app configuration file generated for discorddiffusion on 2024-08-14T17:52:28-04:00 +# fly.toml app configuration file generated for discorddiffusion on 2024-08-14T18:30:35-04:00 # # See https://fly.io/docs/reference/configuration/ for information about how to use this file. # diff --git a/src/commands/utility/sticker.js b/src/commands/utility/sticker.js index 316c9a7..f96c878 100644 --- a/src/commands/utility/sticker.js +++ b/src/commands/utility/sticker.js @@ -59,92 +59,90 @@ module.exports = { await interaction.deferReply({ ephemeral: true }); try { - while (true) { - await query({ - inputs: interaction.options.getString("prompt"), - num_images: 4, - rows: 2, - cols: 2, - }).then((response) => { - const { images, preview } = response; + await query({ + inputs: interaction.options.getString("prompt"), + num_images: 4, + rows: 2, + cols: 2, + }).then((response) => { + const { images, preview } = response; - previewImage = preview; - topLeftImage = images[0]; - topRightImage = images[1]; - bottomLeftImage = images[2]; - bottomRightImage = images[3]; - }); + previewImage = preview; + topLeftImage = images[0]; + topRightImage = images[1]; + bottomLeftImage = images[2]; + bottomRightImage = images[3]; + }); - const previewImagePath = await saveBase64Image(previewImage); - const reply = await interaction.editReply({ - files: [new AttachmentBuilder(previewImagePath)], - components: [row], - ephemeral: true, - }); + const previewImagePath = await saveBase64Image(previewImage); + const reply = await interaction.editReply({ + files: [new AttachmentBuilder(previewImagePath)], + components: [row], + ephemeral: true, + }); - const collector = reply.createMessageComponentCollector({ - ComponentType: ComponentType.Button, - }); + const collector = reply.createMessageComponentCollector({ + ComponentType: ComponentType.Button, + }); - collector.on("collect", async (interaction) => { - if (interaction.customId === "top_left") { - const topLeftPath = await saveBase64Image(topLeftImage); - interaction.reply({ - files: [new AttachmentBuilder(topLeftPath)], - }); - return; - } - if (interaction.customId === "top_right") { - const topRightPath = await saveBase64Image(topRightImage); - interaction.reply({ - files: [new AttachmentBuilder(topRightPath)], - }); - return; - } - if (interaction.customId === "bottom_left") { - const bottomLeftPath = await saveBase64Image(bottomLeftImage); - interaction.reply({ - files: [new AttachmentBuilder(bottomLeftPath)], - }); - return; - } - if (interaction.customId === "bottom_right") { - const bottomRightPath = await saveBase64Image(bottomRightImage); - interaction.reply({ - files: [new AttachmentBuilder(bottomRightPath)], - }); - return; - } - if (interaction.customId === "regenerate") { - // do nothing since we are in a while loop that will only terminate - // when the user makes a selection - // - // interaction.deferReply({ ephemeral: true }); - // await query({ - // inputs: interaction.options.getString("prompt"), - // num_images: 4, - // rows: 2, - // cols: 2, - // }).then((response) => { - // const { images, preview } = response; - // previewImage = preview; - // topLeftImage = images[0]; - // topRightImage = images[1]; - // bottomLeftImage = images[2]; - // bottomRightImage = images[3]; - // }); - // const previewImagePath = await saveBase64Image(previewImage); - // const reply = await interaction.editReply({ - // files: [new AttachmentBuilder(previewImagePath)], - // components: [row], - // ephemeral: true, - // }); - // const collector = reply.createMessageComponentCollector({ - // ComponentType: ComponentType.Button, - // }); - } - }); - } + collector.on("collect", async (interaction) => { + if (interaction.customId === "top_left") { + const topLeftPath = await saveBase64Image(topLeftImage); + interaction.reply({ + files: [new AttachmentBuilder(topLeftPath)], + }); + return; + } + if (interaction.customId === "top_right") { + const topRightPath = await saveBase64Image(topRightImage); + interaction.reply({ + files: [new AttachmentBuilder(topRightPath)], + }); + return; + } + if (interaction.customId === "bottom_left") { + const bottomLeftPath = await saveBase64Image(bottomLeftImage); + interaction.reply({ + files: [new AttachmentBuilder(bottomLeftPath)], + }); + return; + } + if (interaction.customId === "bottom_right") { + const bottomRightPath = await saveBase64Image(bottomRightImage); + interaction.reply({ + files: [new AttachmentBuilder(bottomRightPath)], + }); + return; + } + if (interaction.customId === "regenerate") { + // TODO: + // interaction.deferReply({ ephemeral: true }); + // await query({ + // inputs: interaction.options.getString("prompt"), + // num_images: 4, + // rows: 2, + // cols: 2, + // }).then((response) => { + // const { images, preview } = response; + // previewImage = preview; + // topLeftImage = images[0]; + // topRightImage = images[1]; + // bottomLeftImage = images[2]; + // bottomRightImage = images[3]; + // }); + // const previewImagePath = await saveBase64Image(previewImage); + // const reply = await interaction.editReply({ + // files: [new AttachmentBuilder(previewImagePath)], + // components: [row], + // ephemeral: true, + // }); + // const collector = reply.createMessageComponentCollector({ + // ComponentType: ComponentType.Button, + // }); + + return; + } + }); } catch (error) { await interaction.editReply("/(✖ ᗝ ✖)/ sorry something went wrong"); console.error(`Failed to generate stickers: ${error}`);