From e13cbf46447cf149da54d01562c11a1786f9ebef Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sun, 9 May 2021 23:35:48 -0400 Subject: [PATCH] Don't dispatch thread_join on extraneous THREAD_CREATE dispatches --- discord/state.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/discord/state.py b/discord/state.py index d8c322ace..ec93590b5 100644 --- a/discord/state.py +++ b/discord/state.py @@ -709,14 +709,16 @@ class ConnectionState: def parse_thread_create(self, data): guild_id = int(data['guild_id']) - guild = self._get_guild(guild_id) + guild: Optional[Guild] = self._get_guild(guild_id) if guild is None: log.debug('THREAD_CREATE referencing an unknown guild ID: %s. Discarding', guild_id) return thread = Thread(guild=guild, data=data) + has_thread = guild.get_thread(thread.id) guild._add_thread(thread) - self.dispatch('thread_join', thread) + if not has_thread: + self.dispatch('thread_join', thread) def parse_thread_update(self, data): guild_id = int(data['guild_id'])