Skip to content
Draft
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion hikari/impl/gateway_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,9 @@ def run(
)
)

loop.run_until_complete(self.join())
if self._closed_event is not None:
# The user might have closed the bot during startup, respect it
loop.run_until_complete(self.join())

finally:
try:
Expand Down Expand Up @@ -929,6 +931,10 @@ async def start(
self._voice.start()

await self._event_manager.dispatch(self._event_factory.deserialize_starting_event())
if self._closed_event is None:
# If the user requested to close the bot before startup, respect it
return

requirements = await self._rest.fetch_gateway_bot_info()

if shard_count is None:
Expand Down
9 changes: 8 additions & 1 deletion hikari/impl/rest_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,10 @@ def run(
ssl_context=ssl_context,
)
)
loop.run_until_complete(self.join())

if self._close_event is not None:
# The user might have closed the bot during startup, respect it
loop.run_until_complete(self.join())

finally:
try:
Expand Down Expand Up @@ -677,6 +680,10 @@ async def start(
await self._rest.close()
raise

if self._close_event is None:
# If the user requested to close the bot before startup, respect it
return

await self._server.start(
backlog=backlog,
host=host,
Expand Down