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

feat 💥: fire async start methods as soon as possible #631

Merged
merged 1 commit into from
Sep 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions naff/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down