diff options
| author | Ritabrata Das <[email protected]> | 2025-02-11 23:52:23 +0530 |
|---|---|---|
| committer | Ritabrata Das <[email protected]> | 2025-02-11 23:52:23 +0530 |
| commit | c36334fc1ec9811e20c294eecf465a6c352b2e34 (patch) | |
| tree | d04991c67b4f0cbb0d6bbed866757f5b10cd0ab8 | |
| parent | c222abd31f5f23df6ee549fe2acf7e46dd53219b (diff) | |
Do not crash on disconnected clients
| -rw-r--r-- | lib/discordSync.py | 3 |
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) |
