dolfies / discord.py-self

A fork of the popular discord.py for user accounts.
https://discordpy-self.rtfd.io/en/latest/
MIT License
683 stars 162 forks source link

AttributeError: 'NoneType' object has no attribute 'guild' #349

Closed 0C72 closed 2 years ago

0C72 commented 2 years ago

Summary

AttributeError originating from /discord/threads.py

Reproduction Steps

The only part of my script that uses this library is an on_message event that triggers for every message not sent by a webhook or the user it’s running on.

Code

if __name__ == '__main__':
    webSend('Started')
    class theClient(discord.Client):
        async def on_message(self, msg):
            try:
                if msg.author == self.user: return
                elif msg.webhook_id: return
                # Omitted rest of code because it doesn’t pertain to this.
            except:
                print(traceback.format_exc())

Expected Results

Works as intended 99% of the time, triggering on messages. However, when some event happens (I haven’t dug into it too much myself, but I believe it’s from threads) the AttributeError occurs.

Actual Results

This is the complete traceback:

File "/python/lib/python3.10/site-packages/discord/threads.py", line 783, in init self._from_data(data) File "/python/lib/python3.10/site-packages/discord/threads.py", line 806, in _from_data guild = self.parent.parent.guild # type: ignore AttributeError: 'NoneType' object has no attribute 'guild'

System Information

Python 3.10.6 discord.py-self v2.0.0-alpha discord.py-self pkg_resources: v2.0.0a2

Checklist

Additional Information

No response

dolfies commented 2 years ago

You're on an older commit, upgrade.