Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

Commit

Permalink
feat 💥: fire async start methods as soon as possible (#631)
Browse files Browse the repository at this point in the history
feat: fire async start methods as soon as possible
  • Loading branch information
LordOfPolls committed Sep 14, 2022
1 parent bd61f67 commit 8ef633f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions naff/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,13 +775,6 @@ async def _on_websocket_ready(self, event: events.RawGatewayEvent) -> None:
self.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()
Expand Down Expand Up @@ -848,6 +841,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:
Expand Down

0 comments on commit 8ef633f

Please sign in to comment.