Skip to content

Commit

Permalink
🐝 Change model Autocomplete to Choices
Browse files Browse the repository at this point in the history
  • Loading branch information
Zingzy committed Mar 26, 2024
1 parent 1c13e3c commit b213b80
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions cogs/imagine_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,23 +212,16 @@ async def cog_load(self):
await self.bot.wait_until_ready()
self.bot.add_view(ImagineButtonView())

async def model_autocomplete(self,
interaction: discord.Interaction,
current: str,
) -> list[app_commands.Choice[str]]:

return [
app_commands.Choice(name=choice, value=choice)
for choice in MODELS if current.lower() in choice.lower()
]


@app_commands.command(name="pollinate", description="Generate AI Images")
@app_commands.autocomplete(model=model_autocomplete)
@app_commands.choices(
model=[
app_commands.Choice(name=choice, value=choice) for choice in MODELS
],
)
@app_commands.guild_only()
@app_commands.checks.cooldown(1, 15)
@app_commands.describe(prompt="Imagine a prompt", height="Height of the image", width="Width of the image", negative="The things not to include in the image", cached="Removes the image seed", nologo="Remove the logo", enhance="Disables Prompt enhancing if set to False", private="Only you can see the generated Image if set to True")
async def imagine_command(self, interaction, prompt:str, model: str = "Swizz8", width:int = 1000, height:int = 1000, negative:str|None = None, cached:bool = False, nologo:bool = False, enhance:bool = True, private:bool = False):
@app_commands.describe(prompt="Imagine a prompt", model=f"The AI model to use for generating the image. Default is {MODELS[0]}", height="Height of the image", width="Width of the image", negative="The things not to include in the image", cached="Removes the image seed", nologo="Remove the logo", enhance="Disables Prompt enhancing if set to False", private="Only you can see the generated Image if set to True")
async def imagine_command(self, interaction, prompt:str, model: app_commands.Choice[str] = MODELS[0], width:int = 1000, height:int = 1000, negative:str|None = None, cached:bool = False, nologo:bool = False, enhance:bool = True, private:bool = False):
await interaction.response.send_message(embed=discord.Embed(title="Generating Image", description="Please wait while we generate your image", color=discord.Color.blurple()), ephemeral=True)

if len(prompt) > 1500:
Expand Down

0 comments on commit b213b80

Please sign in to comment.