Skip to content

Commit 88d43dc

Browse files
OmbuchaLulalabyBobDotCom
authored
Rename original_message to original_response (#1609)
* Rename `original_message` to `original_response` * Add Aliases * Fix Errors * Remove Unnecessary `kwargs` * Add Warnings * Improve Warnings * Use `utils.deprecated` * Fix Errors * Update Decorators * Fix Errors * Fix Workflow Errors * Create a Changelog Entry * Update the Changelog * Update CHANGELOG.md * Update CHANGELOG.md Co-authored-by: Lala Sabathil <[email protected]> Co-authored-by: BobDotCom <[email protected]>
1 parent 8764a0e commit 88d43dc

File tree

4 files changed

+78
-20
lines changed

4 files changed

+78
-20
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
- New `BridgeCommand.invoke()` method. ([#1642](https://github.com/Pycord-Development/pycord/pull/1642))
1818
- New `raw_mentions`, `raw_role_mentions` and `raw_channel_mentions` functions in `discord.utils`.
1919
([#1658](https://github.com/Pycord-Development/pycord/pull/1658))
20+
- New methods `original_response`, `edit_original_response` & `delete_original_response` for `Interaction` objects.
21+
([#1609](https://github.com/Pycord-Development/pycord/pull/1609)
22+
2023

2124
### Deprecated
2225
- The `delete_message_days` parameter in ban methods is now deprecated. Please use `delete_message_seconds` instead.
2326
([#1557](https://github.com/Pycord-Development/pycord/pull/1557))
27+
- The `original_message`, `edit_original_message` & `delete_original_message` methods for `Interaction` are now deprecated. Please use the respective `original_response`, `edit_original_response` & `delete_original_response` methods instead.
28+
([#1557](https://github.com/Pycord-Development/pycord/pull/1557))
2429

2530
### Fixed
2631
- Various fixes to ext.bridge groups ([#1633](https://github.com/Pycord-Development/pycord/pull/1633) &

discord/commands/context.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ async def delete(self, *, delay: Optional[float] = None) -> None:
313313
314314
Deletes the original interaction response message.
315315
316-
This is a higher level interface to :meth:`Interaction.delete_original_message`.
316+
This is a higher level interface to :meth:`Interaction.delete_original_response`.
317317
318318
Parameters
319319
-----------
@@ -330,12 +330,12 @@ async def delete(self, *, delay: Optional[float] = None) -> None:
330330
if not self.interaction.response.is_done():
331331
await self.defer()
332332

333-
return await self.interaction.delete_original_message(delay=delay)
333+
return await self.interaction.delete_original_response(delay=delay)
334334

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

340340
@property
341341
def cog(self) -> Optional[Cog]:

discord/ext/pages/pagination.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@ async def respond(
11051105
if isinstance(msg, (discord.Message, discord.WebhookMessage)):
11061106
self.message = msg
11071107
elif isinstance(msg, discord.Interaction):
1108-
self.message = await msg.original_message()
1108+
self.message = await msg.original_response()
11091109

11101110
return self.message
11111111

discord/interactions.py

Lines changed: 68 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class Interaction:
139139
"_app_permissions",
140140
"_state",
141141
"_session",
142-
"_original_message",
142+
"_original_response",
143143
"_cs_app_permissions",
144144
"_cs_response",
145145
"_cs_followup",
@@ -149,7 +149,7 @@ class Interaction:
149149
def __init__(self, *, data: InteractionPayload, state: ConnectionState):
150150
self._state: ConnectionState = state
151151
self._session: ClientSession = state.http._HTTPClient__session
152-
self._original_message: Optional[InteractionMessage] = None
152+
self._original_response: Optional[InteractionMessage] = None
153153
self._from_data(data)
154154

155155
def _from_data(self, data: InteractionPayload):
@@ -263,7 +263,7 @@ def followup(self) -> Webhook:
263263
}
264264
return Webhook.from_state(data=payload, state=self._state)
265265

266-
async def original_message(self) -> InteractionMessage:
266+
async def original_response(self) -> InteractionMessage:
267267
"""|coro|
268268
269269
Fetches the original interaction response message associated with the interaction.
@@ -287,8 +287,8 @@ async def original_message(self) -> InteractionMessage:
287287
The original interaction response message.
288288
"""
289289

290-
if self._original_message is not None:
291-
return self._original_message
290+
if self._original_response is not None:
291+
return self._original_response
292292

293293
# TODO: fix later to not raise?
294294
channel = self.channel
@@ -306,10 +306,28 @@ async def original_message(self) -> InteractionMessage:
306306
)
307307
state = _InteractionMessageState(self, self._state)
308308
message = InteractionMessage(state=state, channel=channel, data=data) # type: ignore
309-
self._original_message = message
309+
self._original_response = message
310310
return message
311311

312-
async def edit_original_message(
312+
@utils.deprecated("Interaction.original_response", "2.1")
313+
async def original_message(self):
314+
"""An alias for :meth:`original_response`.
315+
316+
Raises
317+
-------
318+
HTTPException
319+
Fetching the original response message failed.
320+
ClientException
321+
The channel for the message could not be resolved.
322+
323+
Returns
324+
--------
325+
InteractionMessage
326+
The original interaction response message.
327+
"""
328+
return self.original_response()
329+
330+
async def edit_original_response(
313331
self,
314332
*,
315333
content: Optional[str] = MISSING,
@@ -409,11 +427,33 @@ async def edit_original_message(
409427
self._state.store_view(view, message.id)
410428

411429
if delete_after is not None:
412-
await self.delete_original_message(delay=delete_after)
430+
await self.delete_original_response(delay=delete_after)
413431

414432
return message
415433

416-
async def delete_original_message(self, *, delay: Optional[float] = None) -> None:
434+
@utils.deprecated("Interaction.edit_original_response", "2.1")
435+
async def edit_original_message(self, **kwargs):
436+
"""An alias for :meth:`edit_original_response`.
437+
438+
Raises
439+
-------
440+
HTTPException
441+
Editing the message failed.
442+
Forbidden
443+
Edited a message that is not yours.
444+
TypeError
445+
You specified both ``embed`` and ``embeds`` or ``file`` and ``files``
446+
ValueError
447+
The length of ``embeds`` was invalid.
448+
449+
Returns
450+
--------
451+
:class:`InteractionMessage`
452+
The newly edited message.
453+
"""
454+
return self.edit_original_response(**kwargs)
455+
456+
async def delete_original_response(self, *, delay: Optional[float] = None) -> None:
417457
"""|coro|
418458
419459
Deletes the original interaction response message.
@@ -449,6 +489,19 @@ async def delete_original_message(self, *, delay: Optional[float] = None) -> Non
449489
else:
450490
await func
451491

492+
@utils.deprecated("Interaction.delete_original_response", "2.1")
493+
async def delete_original_message(self, **kwargs):
494+
"""An alias for :meth:`delete_original_response`.
495+
496+
Raises
497+
-------
498+
HTTPException
499+
Deleting the message failed.
500+
Forbidden
501+
Deleted a message that is not yours.
502+
"""
503+
return self.delete_original_response(**kwargs)
504+
452505
def to_dict(self) -> Dict[str, Any]:
453506
"""
454507
Converts this interaction object into a dict.
@@ -761,12 +814,12 @@ async def send_message(
761814
if ephemeral and view.timeout is None:
762815
view.timeout = 15 * 60.0
763816

764-
view.message = await self._parent.original_message()
817+
view.message = await self._parent.original_response()
765818
self._parent._state.store_view(view)
766819

767820
self._responded = True
768821
if delete_after is not None:
769-
await self._parent.delete_original_message(delay=delete_after)
822+
await self._parent.delete_original_response(delay=delete_after)
770823
return self._parent
771824

772825
async def edit_message(
@@ -894,7 +947,7 @@ async def edit_message(
894947

895948
self._responded = True
896949
if delete_after is not None:
897-
await self._parent.delete_original_message(delay=delete_after)
950+
await self._parent.delete_original_response(delay=delete_after)
898951

899952
async def send_autocomplete_result(
900953
self,
@@ -1032,7 +1085,7 @@ class InteractionMessage(Message):
10321085
"""Represents the original interaction response message.
10331086
10341087
This allows you to edit or delete the message associated with
1035-
the interaction response. To retrieve this object see :meth:`Interaction.original_message`.
1088+
the interaction response. To retrieve this object see :meth:`Interaction.original_response`.
10361089
10371090
This inherits from :class:`discord.Message` with changes to
10381091
:meth:`edit` and :meth:`delete` to work.
@@ -1105,7 +1158,7 @@ async def edit(
11051158
"""
11061159
if attachments is MISSING:
11071160
attachments = self.attachments or MISSING
1108-
return await self._state._interaction.edit_original_message(
1161+
return await self._state._interaction.edit_original_response(
11091162
content=content,
11101163
embeds=embeds,
11111164
embed=embed,
@@ -1137,7 +1190,7 @@ async def delete(self, *, delay: Optional[float] = None) -> None:
11371190
HTTPException
11381191
Deleting the message failed.
11391192
"""
1140-
await self._state._interaction.delete_original_message(delay=delay)
1193+
await self._state._interaction.delete_original_response(delay=delay)
11411194

11421195

11431196
class MessageInteraction:

0 commit comments

Comments
 (0)