switched to atiohttp #13

Merged
wirehack7 merged 5 commits from dev into main 2025-05-01 15:56:11 +02:00
2 changed files with 5 additions and 13 deletions
Showing only changes of commit 1ef60193a0 - Show all commits

View File

@ -10,9 +10,9 @@ import sys
import time import time
import zipfile import zipfile
import aiohttp
import discord import discord
import requests import requests
import aiohttp
from discord import app_commands from discord import app_commands
from discord.ext import commands from discord.ext import commands
@ -160,13 +160,7 @@ async def generate(
} }
start_time = time.monotonic() 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 aiohttp.ClientSession() as session:
async with session.post( async with session.post(
"https://image.novelai.net/ai/generate-image", "https://image.novelai.net/ai/generate-image",
@ -221,10 +215,7 @@ async def generate(
except Exception: # pylint: disable=W0718 except Exception: # pylint: disable=W0718
error_data = "error message unreadable" error_data = "error message unreadable"
error_message = ( error_message = f"Error {status_code} at API-request.\n" f"Answer: {error_data}\n"
f"Error {status_code} at API-request.\n"
f"Answer: {error_data}\n"
)
await interaction.followup.send(error_message) await interaction.followup.send(error_message)

View File

@ -1,2 +1,3 @@
discord discord
requests requests
aiohttp