From 4c17fdc45a88dffd215db6b824c8f3e88dfe81b3 Mon Sep 17 00:00:00 2001 From: Skelmis <47520067+Skelmis@users.noreply.github.com> Date: Thu, 25 Aug 2022 05:21:26 +1200 Subject: [PATCH] fix: message initialization failing with threads and no intents (#715) --- changelog/699.bugfix.rst | 1 + changelog/712.bugfix.rst | 1 + disnake/message.py | 7 +++++-- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 changelog/699.bugfix.rst create mode 100644 changelog/712.bugfix.rst diff --git a/changelog/699.bugfix.rst b/changelog/699.bugfix.rst new file mode 100644 index 0000000000..5b49f58ca5 --- /dev/null +++ b/changelog/699.bugfix.rst @@ -0,0 +1 @@ +Fixes message initialization failing with threads and no intents by explicitly checking we have a guild object where one is required. diff --git a/changelog/712.bugfix.rst b/changelog/712.bugfix.rst new file mode 100644 index 0000000000..5b49f58ca5 --- /dev/null +++ b/changelog/712.bugfix.rst @@ -0,0 +1 @@ +Fixes message initialization failing with threads and no intents by explicitly checking we have a guild object where one is required. diff --git a/disnake/message.py b/disnake/message.py index db507b4b64..ccdc412c08 100644 --- a/disnake/message.py +++ b/disnake/message.py @@ -935,7 +935,7 @@ def __init__( self.guild = state._get_guild(utils._get_as_snowflake(data, "guild_id")) if thread_data := data.get("thread"): - if not self.thread and self.guild: + if not self.thread and isinstance(self.guild, Guild): self.guild._store_thread(thread_data) try: @@ -1251,7 +1251,10 @@ def thread(self) -> Optional[Thread]: .. versionadded:: 2.4 """ - return self.guild and self.guild.get_thread(self.id) + if not isinstance(self.guild, Guild): + return None + + return self.guild.get_thread(self.id) def is_system(self) -> bool: """Whether the message is a system message.