diff --git a/discord/message.py b/discord/message.py index 24f21280d..379d786b0 100644 --- a/discord/message.py +++ b/discord/message.py @@ -1763,9 +1763,13 @@ class Message(PartialMessage, Hashable): def _handle_interaction(self, data: MessageInteractionPayload): self.interaction = MessageInteraction(state=self._state, guild=self.guild, data=data) - def _rebind_cached_references(self, new_guild: Guild, new_channel: Union[TextChannel, Thread]) -> None: + def _rebind_cached_references( + self, + new_guild: Guild, + new_channel: Union[GuildChannel, Thread, PartialMessageable], + ) -> None: self.guild = new_guild - self.channel = new_channel + self.channel = new_channel # type: ignore # Not all "GuildChannel" are messageable at the moment @utils.cached_slot_property('_cs_raw_mentions') def raw_mentions(self) -> List[int]: diff --git a/discord/state.py b/discord/state.py index 84b3b8f89..8b556f28c 100644 --- a/discord/state.py +++ b/discord/state.py @@ -65,7 +65,6 @@ from .role import Role from .enums import ChannelType, try_enum, Status from . import utils from .flags import ApplicationFlags, Intents, MemberCacheFlags -from .object import Object from .invite import Invite from .integrations import _integration_factory from .interactions import Interaction @@ -1631,9 +1630,10 @@ class AutoShardedConnectionState(ConnectionState[ClientT]): new_guild = self._get_guild(msg.guild.id) if new_guild is not None and new_guild is not msg.guild: channel_id = msg.channel.id - channel = new_guild._resolve_channel(channel_id) or Object(id=channel_id) - # channel will either be a TextChannel, Thread or Object - msg._rebind_cached_references(new_guild, channel) # type: ignore + channel = new_guild._resolve_channel(channel_id) or PartialMessageable( + state=self, id=channel_id, guild_id=new_guild.id + ) + msg._rebind_cached_references(new_guild, channel) async def chunker( self,