Skip to content

fix: AttributeError when fetching a message from a PartialMessageable that has a thread#3309

Open
Paillat-dev wants to merge 3 commits into
masterfrom
fix/partial-messageable-fetch-thread
Open

fix: AttributeError when fetching a message from a PartialMessageable that has a thread#3309
Paillat-dev wants to merge 3 commits into
masterfrom
fix/partial-messageable-fetch-thread

Conversation

@Paillat-dev

Copy link
Copy Markdown
Member

Summary

When fetching a message that has a thread from a PartialMessageable we don't have a guild so it breaks with:

 AttributeError:'NoneType' object has no attribute 'get_thread'
[...]
# channel is a PartialMessageable
File "[...]" , line 142 , in _get_first_log_message
     return await channel.fetch_message(int(message_id_str))
File "discord/abc.py" , line 1799 , in fetch_message
     return self._state.create_message(channel=channel, data=data)
File "discord/state.py" , line 2056 , in create_message
     return Message(state=self, channel=channel, data=data)
File "discord/message.py" , line 1208 , in __init__
     self.thread = Thread(
File "discord/threads.py" , line 174 , in __init__
     self._from_data(data)
File "discord/threads.py" , line 212 , in _from_data
     if thread := self.guild.get_thread(self.id) and data.pop("_invoke_flag", False): 

Information

  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed).
  • This PR is not a code change (e.g. documentation, README, typehinting,
    examples, ...).

Checklist

  • I have searched the open pull requests for duplicates.
  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why.
  • I have updated the changelog to include these changes.
  • I have read the Contributing Guidelines.
  • AI Usage has been disclosed.
    • If AI has been used, I understand fully what the code does

@Paillat-dev
Paillat-dev requested review from a team and Soheab July 19, 2026 21:14
@Paillat-dev
Paillat-dev requested a review from a team as a code owner July 19, 2026 21:14
@github-project-automation github-project-automation Bot moved this to Todo in Pycord Jul 19, 2026
@pycord-app

pycord-app Bot commented Jul 19, 2026

Copy link
Copy Markdown

Thanks for opening this pull request!
Please make sure you have read the Contributing Guidelines and Code of Conduct.

This pull request can be checked-out with:

git fetch origin pull/3309/head:pr-3309
git checkout pr-3309

This pull request can be installed with:

pip install git+https://github.com/Pycord-Development/pycord@refs/pull/3309/head

@Paillat-dev Paillat-dev changed the title fix: Guard for None guild fix: AttributeError when fetching a message from a PartialMessageable that has a thread Jul 19, 2026
@Paillat-dev Paillat-dev added the bug Something isn't working label Jul 19, 2026
@Paillat-dev

Copy link
Copy Markdown
Member Author

(this would have been fixed by better typing smhhhhhhh)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant