Skip to content

Commit

Permalink
fix(state): prevent DeprecationWarning on shard reconnect (#1267)
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftinv authored Dec 29, 2024
1 parent eea6e6b commit 01cf7f3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions changelog/1267.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Prevent :class:`py:DeprecationWarning` related to :attr:`Message.interaction` field on shard reconnect.
4 changes: 2 additions & 2 deletions disnake/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
8 changes: 4 additions & 4 deletions disnake/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 01cf7f3

Please sign in to comment.