mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-05-16 18:59:09 +00:00
Fix Message.channel rebinding sometimes being Object
This commit is contained in:
parent
742630f144
commit
ec71a46907
@ -1763,9 +1763,13 @@ class Message(PartialMessage, Hashable):
|
|||||||
def _handle_interaction(self, data: MessageInteractionPayload):
|
def _handle_interaction(self, data: MessageInteractionPayload):
|
||||||
self.interaction = MessageInteraction(state=self._state, guild=self.guild, data=data)
|
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.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')
|
@utils.cached_slot_property('_cs_raw_mentions')
|
||||||
def raw_mentions(self) -> List[int]:
|
def raw_mentions(self) -> List[int]:
|
||||||
|
@ -65,7 +65,6 @@ from .role import Role
|
|||||||
from .enums import ChannelType, try_enum, Status
|
from .enums import ChannelType, try_enum, Status
|
||||||
from . import utils
|
from . import utils
|
||||||
from .flags import ApplicationFlags, Intents, MemberCacheFlags
|
from .flags import ApplicationFlags, Intents, MemberCacheFlags
|
||||||
from .object import Object
|
|
||||||
from .invite import Invite
|
from .invite import Invite
|
||||||
from .integrations import _integration_factory
|
from .integrations import _integration_factory
|
||||||
from .interactions import Interaction
|
from .interactions import Interaction
|
||||||
@ -1631,9 +1630,10 @@ class AutoShardedConnectionState(ConnectionState[ClientT]):
|
|||||||
new_guild = self._get_guild(msg.guild.id)
|
new_guild = self._get_guild(msg.guild.id)
|
||||||
if new_guild is not None and new_guild is not msg.guild:
|
if new_guild is not None and new_guild is not msg.guild:
|
||||||
channel_id = msg.channel.id
|
channel_id = msg.channel.id
|
||||||
channel = new_guild._resolve_channel(channel_id) or Object(id=channel_id)
|
channel = new_guild._resolve_channel(channel_id) or PartialMessageable(
|
||||||
# channel will either be a TextChannel, Thread or Object
|
state=self, id=channel_id, guild_id=new_guild.id
|
||||||
msg._rebind_cached_references(new_guild, channel) # type: ignore
|
)
|
||||||
|
msg._rebind_cached_references(new_guild, channel)
|
||||||
|
|
||||||
async def chunker(
|
async def chunker(
|
||||||
self,
|
self,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user