From 9964e2ff7436c04869509bd9a7c255d76ede5437 Mon Sep 17 00:00:00 2001 From: ZeldaFan0225 <78901316+ZeldaFan0225@users.noreply.github.com> Date: Fri, 27 Jan 2023 15:02:19 +0100 Subject: [PATCH] small adjustments --- config.md | 1 + src/contexts/remix.ts | 15 ++++++++++----- src/modals/remix.ts | 9 +++++++-- src/types.ts | 1 + template.config.json | 1 + 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/config.md b/config.md index 5a3861b..33573b0 100644 --- a/config.md +++ b/config.md @@ -182,6 +182,7 @@ Here you can see an explanation of what which option does "trusted_workers": Whether to only use trusted workers (BOOLEAN) *1, "blacklisted_words": A list of blacklisted words which users are not allowed to use (ARRAY OF STRING), "convert_a1111_weight_to_horde_weight": Whether to convert a1111 to weighted prompt required by the api (BOOLEAN) *7 *8, + "allow_custom_strength": Set to true to allow the user to give a custom strength (BOOLEAN), "generation_options": { "sampler_name": The sampler to use for remixing (STRING) *1 *2, "model": The model to use for remixing (STRING) *1 *3, diff --git a/src/contexts/remix.ts b/src/contexts/remix.ts index 79974e3..9885edb 100644 --- a/src/contexts/remix.ts +++ b/src/contexts/remix.ts @@ -1,4 +1,4 @@ -import { ApplicationCommandType, ContextMenuCommandBuilder } from "discord.js"; +import { APIModalInteractionResponseCallbackData, ApplicationCommandType, ContextMenuCommandBuilder } from "discord.js"; import { Context } from "../classes/context"; import { ContextContext } from "../classes/contextContext"; @@ -25,7 +25,7 @@ export default class extends Context { if(!user_token) return ctx.error({error: `You are required to ${await ctx.client.getSlashCommandTag("login")} to use this action`, codeblock: false}) - const modal = { + const modal: APIModalInteractionResponseCallbackData = { title: "Enter Prompt", custom_id: `remix_${target_user.id}`, components: [{ @@ -36,9 +36,14 @@ export default class extends Context { label: "Prompt", custom_id: "prompt", required: true, - placeholder: "Enter a prompt to remix the users avatar with" + placeholder: "Enter a prompt to remix the users avatar with", + value: target_user.username }] - },{ + }] + } + + if(ctx.client.config.remix.allow_custom_strength) { + modal.components.push({ type: 1, components: [{ type: 4, @@ -49,7 +54,7 @@ export default class extends Context { placeholder: "Number between 1 and 100", max_length: 3 }] - }] + }) } await ctx.interaction.showModal(modal) diff --git a/src/modals/remix.ts b/src/modals/remix.ts index 7da36f3..8c3ef5d 100644 --- a/src/modals/remix.ts +++ b/src/modals/remix.ts @@ -79,7 +79,7 @@ export default class extends Modal { console.log(generation_options) } - const message = await ctx.interaction.editReply({content: "Remixing..."}) + const message = await ctx.interaction.editReply({content: `Remixing...`}) const generation_start = await ctx.stable_horde_manager.postAsyncGenerate(generation_data, {token: user_token}) .catch((e) => { @@ -107,7 +107,12 @@ export default class extends Modal { const inter = setInterval(async () => { const status = await ctx.stable_horde_manager.getGenerationCheck(generation_start?.id!) - if(ctx.client.config.advanced?.dev) console.log(status) + if(ctx.client.config.advanced?.dev) { + console.log(status) + if(!status.done && !status.faulted) await message.edit({ + content: `Remixing...\n\n__**DEV**__\n**ID** ${generation_start.id}\n**Eta** ${status.wait_time}s\n**Kudos** ${status.kudos}\n**Possible** ${status.is_possible}` + }) + } if(status.done) await displayResult() else if(status.faulted) displayError() }, 1000 * 5) diff --git a/src/types.ts b/src/types.ts index e0f7af1..15102c6 100644 --- a/src/types.ts +++ b/src/types.ts @@ -261,6 +261,7 @@ export interface Config { trusted_workers?: boolean, blacklisted_words?: string[], convert_a1111_weight_to_horde_weight?: boolean, + allow_custom_strength: boolean, generation_options?: { sampler_name?: string, width?: number, diff --git a/template.config.json b/template.config.json index 61d264d..126a964 100644 --- a/template.config.json +++ b/template.config.json @@ -181,6 +181,7 @@ "trusted_workers": true, "blacklisted_words": [], "convert_a1111_weight_to_horde_weight": true, + "allow_custom_strength": true, "generation_options": { "sampler_name": "k_euler", "model": "stable_diffusion",