Sync with main #4

Merged
wirehack7 merged 12 commits from main into dev 2025-05-01 14:07:15 +02:00
Showing only changes of commit fb52c427e3 - Show all commits

View File

@ -19,18 +19,18 @@ bot = commands.Bot(command_prefix=commands.when_mentioned, intents=intents)
@bot.event
async def on_ready():
print(f"Bot gestartet als {bot.user}")
print(f"Bot started as {bot.user}")
try:
synced = await bot.tree.sync()
print(f"{len(synced)} Slash-Commands synchronisiert.")
print(f"{len(synced)} Slash-Commands synchronized.")
except Exception as e:
print(e)
@bot.tree.command(name="generate", description="Generiere ein Bild mit NovelAI v4")
@bot.tree.command(name="generate", description="Generate image with NovelAI v4 Full")
@app_commands.describe(
prompt="Was soll dargestellt werden?",
undesired_prompt="Was soll vermieden werden? (optional)",
orientation="portrait oder landscape (Standard: portrait)"
prompt="What should be generated?",
undesired_prompt="What should be avoided? (optional)",
orientation="portrait or landscape (Standard: portrait)"
)
async def generate(
interaction: discord.Interaction,
@ -40,7 +40,7 @@ async def generate(
):
if interaction.channel.id != ALLOWED_CHANNEL_ID:
await interaction.response.send_message(
"Dieser Befehl ist in diesem Kanal nicht erlaubt.",
"This command isn't allowed here.",
ephemeral=True
)
return
@ -56,12 +56,7 @@ async def generate(
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, "
)
negative = undesired_prompt.strip() or (
"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"
"blank page, watermarks, watermark, text, "
)
seed = random.randint(0, 2**32 - 1)
@ -93,7 +88,7 @@ async def generate(
"use_coords": False,
"legacy_uc": False,
"normalize_reference_strength_multiple": True,
#"seed": seed,
"seed": seed,
"characterPrompts": [],
"v4_prompt": {
"caption": {
@ -132,7 +127,7 @@ async def generate(
response_bytes = response.content
param_text = f"""```Prompt: {prompt}
Negativer Prompt: {negative}
Negativer Prompt: {default_negative + undesired_prompt.strip()}
Seed: {seed}
Auflösung: {width}x{height}
Sampler: k_euler_ancestral
@ -155,7 +150,7 @@ Model: nai-diffusion-4-full```"""
await interaction.followup.send(content=param_text, file=file)
else:
await interaction.followup.send(
"ZIP erhalten, aber kein PNG-Bild gefunden."
"Found no PNG inside archive"
)
elif response_bytes[:4] == b'\x89PNG':
@ -166,7 +161,7 @@ Model: nai-diffusion-4-full```"""
else:
await interaction.followup.send(
"Die API hat Daten gesendet, aber es war weder ein Bild noch ein gültiges ZIP-Archiv."
"API didn't send any file"
)
else:
@ -175,7 +170,7 @@ Model: nai-diffusion-4-full```"""
except Exception:
error_data = {"error": response.text}
error_message = f"Fehler {response.status_code} bei der API-Anfrage.\n"
error_message = f"Error {response.status_code} at API-request.\n"
for key, value in error_data.items():
error_message += f"**{key}**: {value}\n"