mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 20:28:38 +00:00
Fix unknown DMChannel in MessageReference.resolved.channel
Threads would cause the message reference to resolve to a DMChannel
This commit is contained in:
parent
cfdccbd5ff
commit
2e5da07180
@ -716,8 +716,10 @@ class Message(Hashable):
|
|||||||
# Right now the channel IDs match but maybe in the future they won't.
|
# Right now the channel IDs match but maybe in the future they won't.
|
||||||
if ref.channel_id == channel.id:
|
if ref.channel_id == channel.id:
|
||||||
chan = channel
|
chan = channel
|
||||||
|
elif isinstance(channel, Thread) and channel.parent.id == ref.channel_id:
|
||||||
|
chan = channel
|
||||||
else:
|
else:
|
||||||
chan, _ = state._get_guild_channel(resolved)
|
chan, _ = state._get_guild_channel(resolved, ref.guild_id)
|
||||||
|
|
||||||
# the channel will be the correct type here
|
# the channel will be the correct type here
|
||||||
ref.resolved = self.__class__(channel=chan, data=resolved, state=state) # type: ignore
|
ref.resolved = self.__class__(channel=chan, data=resolved, state=state) # type: ignore
|
||||||
|
@ -446,10 +446,11 @@ class ConnectionState:
|
|||||||
# If presences are enabled then we get back the old guild.large behaviour
|
# If presences are enabled then we get back the old guild.large behaviour
|
||||||
return self._chunk_guilds and not guild.chunked and not (self._intents.presences and not guild.large)
|
return self._chunk_guilds and not guild.chunked and not (self._intents.presences and not guild.large)
|
||||||
|
|
||||||
def _get_guild_channel(self, data: MessagePayload) -> Tuple[Union[Channel, Thread], Optional[Guild]]:
|
def _get_guild_channel(self, data: MessagePayload, guild_id: Optional[int] = None) -> Tuple[Union[Channel, Thread], Optional[Guild]]:
|
||||||
channel_id = int(data['channel_id'])
|
channel_id = int(data['channel_id'])
|
||||||
try:
|
try:
|
||||||
guild = self._get_guild(int(data['guild_id']))
|
guild_id = guild_id or int(data['guild_id'])
|
||||||
|
guild = self._get_guild(guild_id)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
channel = DMChannel._from_message(self, channel_id)
|
channel = DMChannel._from_message(self, channel_id)
|
||||||
guild = None
|
guild = None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user