Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

Commit f594ef8

Browse files
committed
fix(idiom): add client timeouts to idiom and sentence commands
1 parent e05de5d commit f594ef8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

bot.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ async def feedback_error(ctx, error):
321321

322322

323323
async def get_random_sentence() -> str:
324-
async with aiohttp.ClientSession() as client:
324+
async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=10)) as client:
325325
resp = await client.get("https://randomwordgenerator.com/json/sentences.json")
326326
data = await resp.json()
327327
return random.choice(data["data"])["sentence"]
@@ -354,8 +354,10 @@ async def sentence_command(ctx, spoiler: Optional[str]):
354354

355355

356356
async def get_random_idiom() -> dict:
357-
async with aiohttp.ClientSession() as client:
358-
resp = await client.get("https://randomwordgenerator.com/json/phrases.json")
357+
async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=10)) as client:
358+
resp = await client.get(
359+
"https://randomwordgenerator.com/json/phrases.json",
360+
)
359361
data = await resp.json()
360362
return random.choice(data["data"])
361363

0 commit comments

Comments
 (0)