Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

[BUG] Broken DM message reaction events #230

Closed
leestarb opened this issue Jan 28, 2022 · 0 comments · Fixed by #231
Closed

[BUG] Broken DM message reaction events #230

leestarb opened this issue Jan 28, 2022 · 0 comments · Fixed by #231
Assignees
Labels
Bug::Library A bug in the library

Comments

@leestarb
Copy link
Collaborator

Describe the bug
Events are broken
(Only in DM)

To Reproduce

bot = Snake(intents=Intents.ALL, sync_interactions=False, asyncio_debug=True)

The problem is same with MessageReactionAdd , MessageReactionRemove both:

@listen(MessageReactionAdd)
async def mra(e: MessageReactionAdd):
    print('mra')

and

@listen(MessageReactionRemove)
async def mrr(e: MessageReactionRemove):
    print('mrr')

If the message was sent before bot starting:

prints: nothing
logs:

ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-45' coro=<ReactionEvents._on_raw_message_reaction_add() done, defined at PATH\dis_snek\api\events\processors\reaction_events.py:18> exception=AttributeError("'NoneType' object has no attribute 'guild'") created at PATH\python310\lib\asyncio\tasks.py:337>
source_traceback: Object created at (most recent call last):
  File "PATH\bot.py", line 54, in <module>
    bot.start("TOKEN")
  File "PATH\dis_snek\client\client.py", line 602, in start
    self.loop.run_until_complete(self.login(token))
  File "PATH\python310\lib\asyncio\base_events.py", line 628, in run_until_complete
    self.run_forever()
  File "PATH\python310\lib\asyncio\windows_events.py", line 316, in run_forever
    super().run_forever()
  File "PATH\python310\lib\asyncio\base_events.py", line 595, in run_forever
    self._run_once()
  File "PATH\python310\lib\asyncio\base_events.py", line 1873, in _run_once
    handle._run()
  File "PATH\python310\lib\asyncio\events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "PATH\dis_snek\api\gateway\gateway.py", line 428, in dispatch_event
    asyncio.create_task(processor(events.RawGatewayEvent(data, override_name=event_name)))
  File "PATH\python310\lib\asyncio\tasks.py", line 337, in create_task
    task = loop.create_task(coro)
Traceback (most recent call last):
  File "PATH\dis_snek\api\events\processors\reaction_events.py", line 62, in _on_raw_message_reaction_add
    message = await self.cache.get_message(event.data.get("channel_id"), event.data.get("message_id"))
  File "PATH\dis_snek\client\smart_cache.py", line 283, in get_message
    if not message.guild and message.channel.guild:
AttributeError: 'NoneType' object has no attribute 'guild'

Or if after:

prints: nothing
logs:

ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-95' coro=<ReactionEvents._on_raw_message_reaction_add() done, defined at PATH\dis_snek\api\events\processors\reaction_events.py:18> exception=AttributeError("'NoneType' object has no attribute 'id'") created at PATH\python310\lib\asyncio\tasks.py:337>
source_traceback: Object created at (most recent call last):
  File "PATH\bot.py", line 54, in <module>
    bot.start("TOKEN")
  File "PATH\dis_snek\client\client.py", line 602, in start
    self.loop.run_until_complete(self.login(token))
  File "PATH\python310\lib\asyncio\base_events.py", line 628, in run_until_complete
    self.run_forever()
  File "PATH\python310\lib\asyncio\windows_events.py", line 316, in run_forever
    super().run_forever()
  File "PATH\python310\lib\asyncio\base_events.py", line 595, in run_forever
    self._run_once()
  File "PATH\python310\lib\asyncio\base_events.py", line 1873, in _run_once
    handle._run()
  File "PATH\python310\lib\asyncio\events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "PATH\dis_snek\api\gateway\gateway.py", line 428, in dispatch_event
    asyncio.create_task(processor(events.RawGatewayEvent(data, override_name=event_name)))
  File "PATH\python310\lib\asyncio\tasks.py", line 337, in create_task
    task = loop.create_task(coro)
Traceback (most recent call last):
  File "PATH\dis_snek\api\events\processors\reaction_events.py", line 54, in _on_raw_message_reaction_add
    "channel_id": message.channel.id,
AttributeError: 'NoneType' object has no attribute 'id'

Expected behaviour
Methods should be called and no errors raised

Additional information
I've restarted bot many times but, no sense.

In the _on_raw_message_reaction_add method event data (channel_id, message_id) seems to be ok,
I've tried to get the channel and the message in bot on_ready event, but message is still None

3.10.1 Latest dev

Jan got same bug in https://discord.com/channels/870046872864165888/936614850820452403

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug::Library A bug in the library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants