From f5a873548a6bd3761942a045f97f2e54ddd41013 Mon Sep 17 00:00:00 2001 From: wirehack7 Date: Thu, 1 May 2025 13:46:52 +0200 Subject: [PATCH] test logging --- src/main.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main.py b/src/main.py index 9402a25..7d19cac 100644 --- a/src/main.py +++ b/src/main.py @@ -2,6 +2,7 @@ import io import os import random import zipfile +import logging import discord from discord import app_commands from discord.ext import commands @@ -17,14 +18,26 @@ if not all([NOVELAI_API_TOKEN, BOT_TOKEN, ALLOWED_CHANNEL_ID]): intents = discord.Intents.default() bot = commands.Bot(command_prefix=commands.when_mentioned, intents=intents) +async def get_available_antlas(api_token): + headers = { + "Authorization": f"Bearer {api_token}" + } + response = requests.get("https://api.novelai.net/user/info", headers=headers) + if response.status_code == 200: + data = response.json() + return data.get("imageAnlas", 0) + else: + logging.error(f"Fehler beim Abrufen der Antlas: {response.status_code}") + return None + @bot.event async def on_ready(): print(f"Bot started as {bot.user}") try: synced = await bot.tree.sync() - print(f"{len(synced)} Slash-Commands synchronized.") + logging.info(f"{len(synced)} Slash-Commands synchronized.") except Exception as e: - print(e) + logging.error(e) @bot.tree.command(name="generate", description="Generate image with NovelAI v4 Full") @app_commands.describe( @@ -138,6 +151,8 @@ async def generate( ) if response.status_code == 200: + antlas = get_available_antlas(NOVELAI_API_TOKEN) + logging.info("Generated image, current antlas: {antlas}") response_bytes = response.content param_text = f"""```Prompt: {prompt}