Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename original_message to original_response #1609

Merged
merged 27 commits into from
Oct 2, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3024509
Rename `original_message` to `original_response`
Ombucha Aug 31, 2022
d8b9eaa
Add Aliases
Ombucha Aug 31, 2022
193a1d0
Fix Errors
Ombucha Aug 31, 2022
e575c2c
Remove Unnecessary `kwargs`
Ombucha Aug 31, 2022
afde061
Merge branch 'Pycord-Development:master' into master
Ombucha Sep 8, 2022
4955e19
Add Warnings
Ombucha Sep 8, 2022
0333317
Improve Warnings
Ombucha Sep 8, 2022
94318c3
Use `utils.deprecated`
Ombucha Sep 8, 2022
eaa51c1
Fix Errors
Ombucha Sep 8, 2022
e9dca03
Merge branch 'master' into master
Lulalaby Sep 12, 2022
3b1cedf
Merge branch 'master' into master
Ombucha Sep 16, 2022
933dcb1
Merge branch 'master' into master
Ombucha Sep 23, 2022
7925db6
Merge branch 'master' into master
BobDotCom Oct 1, 2022
6b78ab9
Merge branch 'master' into master
BobDotCom Oct 1, 2022
fb52524
Merge branch 'master' into master
Lulalaby Oct 1, 2022
d50023c
Update Decorators
Ombucha Oct 1, 2022
3d06502
Fix Errors
Ombucha Oct 1, 2022
c9f0d74
Fix Workflow Errors
Ombucha Oct 1, 2022
db610b5
Merge branch 'master' into master
BobDotCom Oct 1, 2022
abd3446
Create a Changelog Entry
Ombucha Oct 1, 2022
e59ca4b
Merge branch 'master' into master
Ombucha Oct 1, 2022
78cdd7b
Update the Changelog
Ombucha Oct 2, 2022
5b74177
Merge branch 'master' into master
Ombucha Oct 2, 2022
0d6141e
Update CHANGELOG.md
BobDotCom Oct 2, 2022
955ee9a
Update CHANGELOG.md
BobDotCom Oct 2, 2022
9e41f62
Merge branch 'master' into master
BobDotCom Oct 2, 2022
a9b6f15
Merge branch 'master' into master
BobDotCom Oct 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions discord/commands/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ async def delete(self, *, delay: Optional[float] = None) -> None:

Deletes the original interaction response message.

This is a higher level interface to :meth:`Interaction.delete_original_message`.
This is a higher level interface to :meth:`Interaction.delete_original_response`.

Parameters
-----------
Expand All @@ -330,12 +330,12 @@ async def delete(self, *, delay: Optional[float] = None) -> None:
if not self.interaction.response.is_done():
await self.defer()

return await self.interaction.delete_original_message(delay=delay)
return await self.interaction.delete_original_response(delay=delay)

@property
@discord.utils.copy_doc(Interaction.edit_original_message)
@discord.utils.copy_doc(Interaction.edit_original_response)
def edit(self) -> Callable[..., Awaitable[InteractionMessage]]:
return self.interaction.edit_original_message
return self.interaction.edit_original_response

@property
def cog(self) -> Optional[Cog]:
Expand Down
2 changes: 1 addition & 1 deletion discord/ext/pages/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ async def respond(
if isinstance(msg, (discord.Message, discord.WebhookMessage)):
self.message = msg
elif isinstance(msg, discord.Interaction):
self.message = await msg.original_message()
self.message = await msg.original_response()

return self.message

Expand Down
83 changes: 68 additions & 15 deletions discord/interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class Interaction:
"_app_permissions",
"_state",
"_session",
"_original_message",
"_original_response",
"_cs_app_permissions",
"_cs_response",
"_cs_followup",
Expand All @@ -149,7 +149,7 @@ class Interaction:
def __init__(self, *, data: InteractionPayload, state: ConnectionState):
self._state: ConnectionState = state
self._session: ClientSession = state.http._HTTPClient__session
self._original_message: Optional[InteractionMessage] = None
self._original_response: Optional[InteractionMessage] = None
self._from_data(data)

def _from_data(self, data: InteractionPayload):
Expand Down Expand Up @@ -263,7 +263,7 @@ def followup(self) -> Webhook:
}
return Webhook.from_state(data=payload, state=self._state)

async def original_message(self) -> InteractionMessage:
async def original_response(self) -> InteractionMessage:
"""|coro|

Fetches the original interaction response message associated with the interaction.
Expand All @@ -287,8 +287,8 @@ async def original_message(self) -> InteractionMessage:
The original interaction response message.
"""

if self._original_message is not None:
return self._original_message
if self._original_response is not None:
return self._original_response

# TODO: fix later to not raise?
channel = self.channel
Expand All @@ -303,10 +303,28 @@ async def original_message(self) -> InteractionMessage:
)
state = _InteractionMessageState(self, self._state)
message = InteractionMessage(state=state, channel=channel, data=data) # type: ignore
self._original_message = message
self._original_response = message
return message

async def edit_original_message(
@utils.deprecated("Interaction.original_response")
async def original_message(self):
Ombucha marked this conversation as resolved.
Show resolved Hide resolved
"""An alias for :meth:`original_response`.

Raises
-------
HTTPException
Fetching the original response message failed.
ClientException
The channel for the message could not be resolved.

Returns
--------
InteractionMessage
The original interaction response message.
"""
return self.original_response()
Ombucha marked this conversation as resolved.
Show resolved Hide resolved

async def edit_original_response(
self,
*,
content: Optional[str] = MISSING,
Expand Down Expand Up @@ -403,11 +421,33 @@ async def edit_original_message(
self._state.store_view(view, message.id)

if delete_after is not None:
await self.delete_original_message(delay=delete_after)
await self.delete_original_response(delay=delete_after)

return message

async def delete_original_message(self, *, delay: Optional[float] = None) -> None:
@utils.deprecated("Interaction.edit_original_response")
async def edit_original_message(self, **kwargs):
"""An alias for :meth:`edit_original_response`.

Raises
-------
HTTPException
Editing the message failed.
Forbidden
Edited a message that is not yours.
TypeError
You specified both ``embed`` and ``embeds`` or ``file`` and ``files``
ValueError
The length of ``embeds`` was invalid.

Returns
--------
:class:`InteractionMessage`
The newly edited message.
"""
return self.edit_original_response(**kwargs)

async def delete_original_response(self, *, delay: Optional[float] = None) -> None:
"""|coro|

Deletes the original interaction response message.
Expand Down Expand Up @@ -440,6 +480,19 @@ async def delete_original_message(self, *, delay: Optional[float] = None) -> Non
else:
await func

@utils.deprecated("Interaction.delete_original_response")
async def delete_original_message(self, **kwargs):
"""An alias for :meth:`delete_original_response`.

Raises
-------
HTTPException
Deleting the message failed.
Forbidden
Deleted a message that is not yours.
"""
return self.delete_original_response(**kwargs)

def to_dict(self) -> Dict[str, Any]:
"""
Converts this interaction object into a dict.
Expand Down Expand Up @@ -743,12 +796,12 @@ async def send_message(
if ephemeral and view.timeout is None:
view.timeout = 15 * 60.0

view.message = await self._parent.original_message()
view.message = await self._parent.original_response()
self._parent._state.store_view(view)

self._responded = True
if delete_after is not None:
await self._parent.delete_original_message(delay=delete_after)
await self._parent.delete_original_response(delay=delete_after)
return self._parent

async def edit_message(
Expand Down Expand Up @@ -873,7 +926,7 @@ async def edit_message(

self._responded = True
if delete_after is not None:
await self._parent.delete_original_message(delay=delete_after)
await self._parent.delete_original_response(delay=delete_after)

async def send_autocomplete_result(
self,
Expand Down Expand Up @@ -1003,7 +1056,7 @@ class InteractionMessage(Message):
"""Represents the original interaction response message.

This allows you to edit or delete the message associated with
the interaction response. To retrieve this object see :meth:`Interaction.original_message`.
the interaction response. To retrieve this object see :meth:`Interaction.original_response`.

This inherits from :class:`discord.Message` with changes to
:meth:`edit` and :meth:`delete` to work.
Expand Down Expand Up @@ -1076,7 +1129,7 @@ async def edit(
"""
if attachments is MISSING:
attachments = self.attachments or MISSING
return await self._state._interaction.edit_original_message(
return await self._state._interaction.edit_original_response(
content=content,
embeds=embeds,
embed=embed,
Expand Down Expand Up @@ -1108,7 +1161,7 @@ async def delete(self, *, delay: Optional[float] = None) -> None:
HTTPException
Deleting the message failed.
"""
await self._state._interaction.delete_original_message(delay=delay)
await self._state._interaction.delete_original_response(delay=delay)


class MessageInteraction:
Expand Down