fix timeout error when bot boots and loading this cog

This commit is contained in:
brandons209 2021-06-30 19:46:39 -04:00
parent 6df616443f
commit 35ead5152c
2 changed files with 5 additions and 2 deletions

View file

@ -3,7 +3,6 @@ from .activitylog import ActivityLogger
__red_end_user_data_statement__ = "Depending on setup, can log user messages, voice channel activity, audit actions in guilds, activity statistics per guild, user name changes, and any moderation actions per guild."
async def setup(bot):
def setup(bot):
n = ActivityLogger(bot)
await n.initialize()
bot.add_cog(n)

View file

@ -89,6 +89,7 @@ class ActivityLogger(commands.Cog):
# remove userinfo since we are replacing it
self.bot.remove_command("userinfo")
self.load_task = asyncio.create_task(self.initialize())
def cog_unload(self):
self.lock = True
@ -96,6 +97,9 @@ class ActivityLogger(commands.Cog):
for h in self.handles.values():
h.close()
if self.load_task:
self.load_task.cancel()
async def initialize(self):
await self.bot.wait_until_ready()