-
Notifications
You must be signed in to change notification settings - Fork 26
Closed
Description
Is your feature request related to a problem? Please describe.
discord.py 2.4.0 adds the support for reaction type (Rapptz/discord.py#9836) and this breaks the existing tests including the add_reaction().
Specifically, it raises KeyError: 'type' when running test:
ERROR discord.client:client.py:523 Ignoring exception in on_message
Traceback (most recent call last):
File "/Users/user/work/mybot/.venv/lib/python3.12/site-packages/discord/client.py", line 449, in _run_event
await coro(*args, **kwargs)
File "/Users/user/work/mybot/src/cogs/songlink.py", line 54, in convert_apple_music_link
await message.add_reaction(
File "/Users/user/work/mybot/.venv/lib/python3.12/site-packages/discord/message.py", line 1258, in add_reaction
await self._state.http.add_reaction(self.channel.id, self.id, emoji)
File "/Users/user/work/mybot/.venv/lib/python3.12/site-packages/discord/ext/test/backend.py", line 243, in add_reaction
add_reaction(message, user, emoji)
File "/Users/user/work/mybot/.venv/lib/python3.12/site-packages/discord/ext/test/backend.py", line 983, in add_reaction
state.parse_message_reaction_add(data)
File "/Users/user/work/mybot/.venv/lib/python3.12/site-packages/discord/state.py", line 714, in parse_message_reaction_add
raw = RawReactionActionEvent(data, emoji, 'REACTION_ADD')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/user/work/mybot/.venv/lib/python3.12/site-packages/discord/raw_models.py", line 254, in __init__
self.type: ReactionType = try_enum(ReactionType, data['type'])
~~~~^^^^^^^^
KeyError: 'type'
Describe the solution you'd like
When I add type field in backend.py::add_reaction() the tests are successful.
data = {
"message_id": message.id,
"channel_id": message.channel.id,
"user_id": user.id,
"emoji": emoji,
"type": discord.enums.ReactionType.normal, # add
}dpytest/discord/ext/test/backend.py
Lines 969 to 974 in 61cd0fb
| data = { | |
| "message_id": message.id, | |
| "channel_id": message.channel.id, | |
| "user_id": user.id, | |
| "emoji": emoji | |
| } |
Describe alternatives you've considered
I'm ready to open PR but I don't fully understand how can I add test for this issue yet.
Additional context
I'm using discord.py 2.4.0 and dpytest 0.7.0.
It seems reaction type has been added in this commit: Rapptz/discord.py@f77ba71
Metadata
Metadata
Assignees
Labels
No labels