Description
Summary
When an ephemeral message is sent, the resulting Message
object dispatched to on_message
has a channel
attribute that is an instance of DMChannel
, even if the ephemeral message was not sent as a Direct Message.
Reproduction Steps
- Send an ephemeral message (not as a DM, e.g. in a text channel)
- Check
type(message.channel)
for the corresponding message inon_message
Expected Results
message.channel
should be the proper type (e.g. TextChannel
), rather than DMChannel
.
Actual Results
message.channel
is a DMChannel
.
Intents
N/A
System Information
- Python v3.9.5-final
- discord.py v2.0.0-alpha
- discord.py pkg_resources: v2.0.0a3469+g1e17b7fc
- aiohttp v3.7.4.post0
- system info: Windows 10 10.0.19042
Checklist
- I have searched the open issues for duplicates.
- I have shown the entire traceback, if possible.
- I have removed my token from display, if visible.
Additional Context
This seems to be because Discord's API does not provide guild_id
for ephemeral messages for the Message Create event.
When discord.py receives the event, ConnectionState.parse_message_create
assigns the channel with ConnectionState._get_guild_channel
:
Lines 509 to 511 in 1e17b7f
When the data doesn't have guild_id
, ConnectionState._get_guild_channel
returns a DMChannel
:
Lines 403 to 413 in 1e17b7f