From 1ef60193a049acd56e70b77592a90af7ccb24925 Mon Sep 17 00:00:00 2001 From: wirehack7 Date: Thu, 1 May 2025 15:55:54 +0200 Subject: [PATCH] more fixes --- src/main.py | 15 +++------------ src/requirements.txt | 3 ++- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/main.py b/src/main.py index d74c403..fccef60 100644 --- a/src/main.py +++ b/src/main.py @@ -10,9 +10,9 @@ import sys import time import zipfile +import aiohttp import discord import requests -import aiohttp from discord import app_commands from discord.ext import commands @@ -160,13 +160,7 @@ async def generate( } start_time = time.monotonic() - response = requests.post( - "https://image.novelai.net/ai/generate-image", - json=payload, - headers=headers, - timeout=120, - ) - + async with aiohttp.ClientSession() as session: async with session.post( "https://image.novelai.net/ai/generate-image", @@ -221,10 +215,7 @@ async def generate( except Exception: # pylint: disable=W0718 error_data = "error message unreadable" - error_message = ( - f"Error {status_code} at API-request.\n" - f"Answer: {error_data}\n" - ) + error_message = f"Error {status_code} at API-request.\n" f"Answer: {error_data}\n" await interaction.followup.send(error_message) diff --git a/src/requirements.txt b/src/requirements.txt index a19c97b..47ef825 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -1,2 +1,3 @@ discord -requests \ No newline at end of file +requests +aiohttp \ No newline at end of file