Skip to content

Commit a6d93ec

Browse files
authored
refactor: move delete to base context (#1219)
1 parent 646e16c commit a6d93ec

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

interactions/client/context.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,28 @@ async def has_permissions(
414414
else:
415415
return any(perm in self.author.permissions for perm in permissions)
416416

417+
async def delete(self) -> None:
418+
"""
419+
This deletes the interaction response of a message sent by
420+
the contextually derived information from this class.
421+
422+
.. note::
423+
Doing this will proceed in the context message no longer
424+
being present.
425+
"""
426+
if self.responded and self.message is not None:
427+
await self._client.delete_interaction_response(
428+
application_id=str(self.application_id),
429+
token=self.token,
430+
message_id=int(self.message.id),
431+
)
432+
else:
433+
await self._client.delete_interaction_response(
434+
application_id=str(self.application_id), token=self.token
435+
)
436+
437+
self.message = None
438+
417439

418440
@define()
419441
class CommandContext(_Context):
@@ -613,28 +635,6 @@ async def send(self, content: Optional[str] = MISSING, **kwargs) -> Message:
613635
author={"_client": self._client, "id": None, "username": None, "discriminator": None},
614636
)
615637

616-
async def delete(self) -> None:
617-
"""
618-
This deletes the interaction response of a message sent by
619-
the contextually derived information from this class.
620-
621-
.. note::
622-
Doing this will proceed in the context message no longer
623-
being present.
624-
"""
625-
if self.responded and self.message is not None:
626-
await self._client.delete_interaction_response(
627-
application_id=str(self.application_id),
628-
token=self.token,
629-
message_id=int(self.message.id),
630-
)
631-
else:
632-
await self._client.delete_interaction_response(
633-
application_id=str(self.application_id), token=self.token
634-
)
635-
636-
self.message = None
637-
638638
async def populate(self, choices: Union[Choice, List[Choice]]) -> List[Choice]:
639639
"""
640640
This "populates" the list of choices that the client-end

0 commit comments

Comments
 (0)