fix: Update giveaway cog to use asyncio.create_task for better async handling and restore views on cog load

This commit is contained in:
Slipstream 2025-05-30 16:30:24 -06:00
parent e593925383
commit 227bc630ee
Signed by: slipstream
GPG Key ID: 13E498CE010AC6FD

View File

@ -172,12 +172,15 @@ class GiveawaysCog(commands.Cog, name="Giveaways"):
# "ended": bool
# }
# Ensure data directory exists before loading/saving
self.bot.loop.create_task(self._ensure_data_dir_exists()) # Run asynchronously
self.bot.loop.create_task(self.load_giveaways()) # Run asynchronously
asyncio.create_task(self._ensure_data_dir_exists()) # Run asynchronously
asyncio.create_task(self.load_giveaways()) # Run asynchronously
self.check_giveaways_loop.start()
# Persistent views are added in setup_hook
async def cog_load(self): # Changed from setup_hook to cog_load for better timing with bot ready
asyncio.create_task(self._restore_views())
async def _restore_views(self):
await self.bot.wait_until_ready()
print("Re-adding persistent giveaway views...")
temp_loaded_giveaways = [] # Use a temporary list for loading