Skip to content

Commit

Permalink
small adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeldaFan0225 committed Jan 27, 2023
1 parent bf9a2d9 commit 9964e2f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 10 additions & 5 deletions src/contexts/remix.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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: [{
Expand All @@ -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,
Expand All @@ -49,7 +54,7 @@ export default class extends Context {
placeholder: "Number between 1 and 100",
max_length: 3
}]
}]
})
}

await ctx.interaction.showModal(modal)
Expand Down
9 changes: 7 additions & 2 deletions src/modals/remix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions template.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 9964e2f

Please sign in to comment.