From 6827c02e738a36af4bb316ddccfef83b9a0b145b Mon Sep 17 00:00:00 2001 From: Damego Date: Tue, 10 Jan 2023 16:16:44 +0500 Subject: [PATCH] refactor: move `delete` to base context --- interactions/client/context.py | 44 +++++++++++++++++----------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/interactions/client/context.py b/interactions/client/context.py index 57c65117b..d3dcfc090 100644 --- a/interactions/client/context.py +++ b/interactions/client/context.py @@ -414,6 +414,28 @@ async def has_permissions( else: return any(perm in self.author.permissions for perm in permissions) + async def delete(self) -> None: + """ + This deletes the interaction response of a message sent by + the contextually derived information from this class. + + .. note:: + Doing this will proceed in the context message no longer + being present. + """ + if self.responded and self.message is not None: + await self._client.delete_interaction_response( + application_id=str(self.application_id), + token=self.token, + message_id=int(self.message.id), + ) + else: + await self._client.delete_interaction_response( + application_id=str(self.application_id), token=self.token + ) + + self.message = None + @define() class CommandContext(_Context): @@ -613,28 +635,6 @@ async def send(self, content: Optional[str] = MISSING, **kwargs) -> Message: author={"_client": self._client, "id": None, "username": None, "discriminator": None}, ) - async def delete(self) -> None: - """ - This deletes the interaction response of a message sent by - the contextually derived information from this class. - - .. note:: - Doing this will proceed in the context message no longer - being present. - """ - if self.responded and self.message is not None: - await self._client.delete_interaction_response( - application_id=str(self.application_id), - token=self.token, - message_id=int(self.message.id), - ) - else: - await self._client.delete_interaction_response( - application_id=str(self.application_id), token=self.token - ) - - self.message = None - async def populate(self, choices: Union[Choice, List[Choice]]) -> List[Choice]: """ This "populates" the list of choices that the client-end