From 6e1fad16f044132d12d35a40893bd6e4c20c546d Mon Sep 17 00:00:00 2001 From: Rafael Bradley <84998222+Nekidev@users.noreply.github.com> Date: Sat, 26 Oct 2024 14:42:59 -0300 Subject: [PATCH] feat(bot): Restart heartbeat on shard reconnect. --- payphone/bot.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/payphone/bot.py b/payphone/bot.py index 73e91a9..a8813a2 100644 --- a/payphone/bot.py +++ b/payphone/bot.py @@ -124,8 +124,15 @@ class Payphone(commands.AutoShardedBot): print(f"Shard {shard_id} was resumed!") - async def on_shard_disconnect(shard_id: int) -> None: - self.update_heartbeat.cancel() + async def on_shard_connect(self, shard_id: int) -> None: + try: + self.update_heartbeat.start() + + except RuntimeError: + pass + + async def on_shard_disconnect(self, shard_id: int) -> None: + self.update_heartbeat.cancel() async def get_or_fetch_channel( self, channel_id: int