mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-05-16 10:49:24 +00:00
Fix Message.channel rebinding sometimes being Object
This commit is contained in:
parent
742630f144
commit
ec71a46907
discord
@ -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]:
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user