add load_text_async()
from discord.ext import commands
+import aiofiles
import discord
import logging
import asyncpg
@@ -56,3 +57,12 @@ def load_text() -> ClassyDict:
text.update(json.load(f))
return ClassyDict(text)
+
+async def load_text_async() -> ClassyDict:
+ text = {}
+
+ for filename in os.listdir("data/text"):
+ async with aiofiles.open(f"data/text/{filename}", "r", encoding="utf8") as f:
+ text.update(json.load(f))
+
+ return ClassyDict(text)
