diff --git a/src/main.py b/src/main.py index 3fd9bbd..9402a25 100644 --- a/src/main.py +++ b/src/main.py @@ -30,14 +30,23 @@ async def on_ready(): @app_commands.describe( prompt="What should be generated?", undesired_prompt="What should be avoided? (optional)", - orientation="portrait or landscape (Standard: portrait)" + orientation="portrait or landscape (Standard: portrait)", + seed="Optional seed (integer). If empty, a random one will be generated" ) async def generate( interaction: discord.Interaction, prompt: str, undesired_prompt: str = "", - orientation: str = "portrait" + orientation: str = "portrait", + seed: int = None ): + + default_negative = ( + "blurry, lowres, error, film grain, scan artifacts, worst quality, bad quality, jpeg artifacts, " + "very displeasing, chromatic aberration, multiple views, logo, too many watermarks, white blank page, " + "blank page, watermarks, watermark, text, " + ) + if interaction.channel.id != ALLOWED_CHANNEL_ID: await interaction.response.send_message( "This command isn't allowed here.", @@ -51,7 +60,7 @@ async def generate( await interaction.followup.send(f"Prompt too long! Maximum {MAX_PROMPT_LENGTH} chars allowed.") return - if len(negative) > MAX_PROMPT_LENGTH: + if len(default_negative + undesired_prompt.strip()) > MAX_PROMPT_LENGTH: await interaction.followup.send(f"Negative Prompt too long! Maximum {MAX_PROMPT_LENGTH} chars allowed.") return @@ -63,13 +72,8 @@ async def generate( else: width, height = 832, 1216 - default_negative = ( - "blurry, lowres, error, film grain, scan artifacts, worst quality, bad quality, jpeg artifacts, " - "very displeasing, chromatic aberration, multiple views, logo, too many watermarks, white blank page, " - "blank page, watermarks, watermark, text, " - ) - - seed = random.randint(0, 2**32 - 1) + if seed is None: + seed = random.randint(0, 2**32 - 1) # API-Payload zusammenbauen payload = {