aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRitabrata Das <[email protected]>2025-02-11 23:52:23 +0530
committerRitabrata Das <[email protected]>2025-02-11 23:52:23 +0530
commitc36334fc1ec9811e20c294eecf465a6c352b2e34 (patch)
treed04991c67b4f0cbb0d6bbed866757f5b10cd0ab8
parentc222abd31f5f23df6ee549fe2acf7e46dd53219b (diff)
Do not crash on disconnected clients
-rw-r--r--lib/discordSync.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/discordSync.py b/lib/discordSync.py
index dc94bbd..e85a92f 100644
--- a/lib/discordSync.py
+++ b/lib/discordSync.py
@@ -75,6 +75,9 @@ async def monitor_channel(channel_id, playerList:list):
if not message['author'].get('bot'): # Skip messages from bot
encoded_msg = txtMsgr.encode(f"[Discord] {message['author']['username']}: {message['content']}", True)
for player in playerList:
+ if player.streamWriterObject.is_closing():
+ playerList.remove(player) # Remove disconnected players
+ continue # Skip this player
player.streamWriterObject.write(encoded_msg)
await player.streamWriterObject.drain()
on_new_message(message)