switched to atiohttp #13
13
src/main.py
13
src/main.py
@ -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,12 +160,6 @@ 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(
|
||||||
@ -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)
|
||||||
|
|
||||||
|
|||||||
@ -1,2 +1,3 @@
|
|||||||
discord
|
discord
|
||||||
requests
|
requests
|
||||||
|
aiohttp
|
||||||
Loading…
x
Reference in New Issue
Block a user