Skip to content

Commit

Permalink
fix: message initialization failing with threads and no intents (#715)
Browse files Browse the repository at this point in the history
  • Loading branch information
Skelmis authored Aug 24, 2022
1 parent 9207d75 commit 4c17fdc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog/699.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes message initialization failing with threads and no intents by explicitly checking we have a guild object where one is required.
1 change: 1 addition & 0 deletions changelog/712.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes message initialization failing with threads and no intents by explicitly checking we have a guild object where one is required.
7 changes: 5 additions & 2 deletions disnake/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 4c17fdc

Please sign in to comment.