Remove in-place edits and return fresh instances instead

Fixes #4098
This commit is contained in:
Rapptz
2021-08-23 23:46:50 -04:00
parent 9d4fa0341e
commit 490bbffc93
15 changed files with 251 additions and 82 deletions

View File

@ -261,7 +261,7 @@ class Interaction:
files: List[File] = MISSING,
view: Optional[View] = MISSING,
allowed_mentions: Optional[AllowedMentions] = None,
):
) -> InteractionMessage:
"""|coro|
Edits the original interaction response message.
@ -302,7 +302,12 @@ class Interaction:
TypeError
You specified both ``embed`` and ``embeds`` or ``file`` and ``files``
ValueError
The length of ``embeds`` was invalid
The length of ``embeds`` was invalid.
Returns
--------
:class:`InteractionMessage`
The newly edited message.
"""
previous_mentions: Optional[AllowedMentions] = self._state.allowed_mentions
@ -326,8 +331,11 @@ class Interaction:
files=params.files,
)
# The message channel types should always match
message = InteractionMessage(state=self._state, channel=self.channel, data=data) # type: ignore
if view and not view.is_finished():
self._state.store_view(view, int(data['id']))
self._state.store_view(view, message.id)
return message
async def delete_original_message(self) -> None:
"""|coro|
@ -672,7 +680,7 @@ class InteractionMessage(Message):
files: List[File] = MISSING,
view: Optional[View] = MISSING,
allowed_mentions: Optional[AllowedMentions] = None,
):
) -> InteractionMessage:
"""|coro|
Edits the message.
@ -707,9 +715,14 @@ class InteractionMessage(Message):
TypeError
You specified both ``embed`` and ``embeds`` or ``file`` and ``files``
ValueError
The length of ``embeds`` was invalid
The length of ``embeds`` was invalid.
Returns
---------
:class:`InteractionMessage`
The newly edited message.
"""
await self._state._interaction.edit_original_message(
return await self._state._interaction.edit_original_message(
content=content,
embeds=embeds,
embed=embed,