From 9835706c2e7d1387d1b9dd3f5d026770c133abd9 Mon Sep 17 00:00:00 2001 From: LordOfPolls Date: Fri, 9 Sep 2022 08:53:27 +0100 Subject: [PATCH] feat: fire async start methods as soon as possible --- naff/client/client.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/naff/client/client.py b/naff/client/client.py index 6f8e99648..8f99739d2 100644 --- a/naff/client/client.py +++ b/naff/client/client.py @@ -771,13 +771,6 @@ async def _on_websocket_ready(self, event: events.RawGatewayEvent) -> None: logger.debug(f"Waiting for {guild.id} to chunk") await guild.chunked.wait() - # run any pending startup tasks - if self.async_startup_tasks: - try: - await asyncio.gather(*self.async_startup_tasks) - except Exception as e: - self.dispatch(events.Error("async-extension-loader", e)) - # cache slash commands if not self._startup: await self._init_interactions() @@ -844,6 +837,14 @@ async def astart(self, token: str) -> None: token: Your bot's token """ await self.login(token) + + # run any pending startup tasks + if self.async_startup_tasks: + try: + await asyncio.gather(*self.async_startup_tasks) + except Exception as e: + self.dispatch(events.Error("async-extension-loader", e)) + try: await self._connection_state.start() finally: