test logging
This commit is contained in:
parent
7d3fd7ad9a
commit
f5a873548a
19
src/main.py
19
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}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user