From a796eaae0d2cd402e13ac1ee9c5fb13dcb37a6ef Mon Sep 17 00:00:00 2001 From: shiftinv Date: Sun, 29 Dec 2024 22:00:00 +0100 Subject: [PATCH 1/2] fix(state): prevent `DeprecationWarning` on shard reconnect --- disnake/message.py | 4 ++-- disnake/state.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/disnake/message.py b/disnake/message.py index e4cb7ee0e6..72134988bc 100644 --- a/disnake/message.py +++ b/disnake/message.py @@ -1446,8 +1446,8 @@ def _rebind_cached_references(self, new_guild: Guild, new_channel: GuildMessagea # updated later in _update_member_references, after re-chunking if isinstance(self.author, Member): self.author.guild = new_guild - if self.interaction and isinstance(self.interaction.user, Member): - self.interaction.user.guild = new_guild + if self._interaction and isinstance(self._interaction.user, Member): + self._interaction.user.guild = new_guild @utils.cached_slot_property("_cs_raw_mentions") def raw_mentions(self) -> List[int]: diff --git a/disnake/state.py b/disnake/state.py index 54facfc626..0c1f7238da 100644 --- a/disnake/state.py +++ b/disnake/state.py @@ -2433,10 +2433,10 @@ def _update_member_references(self) -> None: if new_author is not None and new_author is not msg.author: msg.author = new_author - if msg.interaction is not None and isinstance(msg.interaction.user, Member): - new_author = msg.guild.get_member(msg.interaction.user.id) - if new_author is not None and new_author is not msg.interaction.user: - msg.interaction.user = new_author + if msg._interaction is not None and isinstance(msg._interaction.user, Member): + new_author = msg.guild.get_member(msg._interaction.user.id) + if new_author is not None and new_author is not msg._interaction.user: + msg._interaction.user = new_author async def chunker( self, From 695cd74e7e78244f4a81af23a534a2f9e28dd2d1 Mon Sep 17 00:00:00 2001 From: shiftinv Date: Sun, 29 Dec 2024 22:01:44 +0100 Subject: [PATCH 2/2] docs: add changelog entry --- changelog/1267.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/1267.bugfix.rst diff --git a/changelog/1267.bugfix.rst b/changelog/1267.bugfix.rst new file mode 100644 index 0000000000..1df3410644 --- /dev/null +++ b/changelog/1267.bugfix.rst @@ -0,0 +1 @@ +Prevent :class:`py:DeprecationWarning` related to :attr:`Message.interaction` field on shard reconnect.