Add edit and delete methods to AppCommand

This commit is contained in:
z03h
2022-05-05 03:20:55 -07:00
committed by GitHub
parent 9793fba338
commit bd727d2b0c
4 changed files with 161 additions and 13 deletions

View File

@ -57,6 +57,7 @@ from .errors import (
CommandNotFound,
CommandSignatureMismatch,
CommandLimitReached,
MissingApplicationID,
)
from ..errors import ClientException
from ..enums import AppCommandType, InteractionType
@ -78,11 +79,6 @@ __all__ = ('CommandTree',)
ClientT = TypeVar('ClientT', bound='Client')
APP_ID_NOT_FOUND = (
'Client does not have an application_id set. Either the function was called before on_ready '
'was called or application_id was not passed to the Client constructor.'
)
def _retrieve_guild_ids(
command: Any, guild: Optional[Snowflake] = MISSING, guilds: Sequence[Snowflake] = MISSING
@ -158,7 +154,7 @@ class CommandTree(Generic[ClientT]):
-------
HTTPException
Fetching the commands failed.
ClientException
MissingApplicationID
The application ID could not be found.
Returns
@ -167,7 +163,7 @@ class CommandTree(Generic[ClientT]):
The application's commands.
"""
if self.client.application_id is None:
raise ClientException(APP_ID_NOT_FOUND)
raise MissingApplicationID
if guild is None:
commands = await self._http.get_global_commands(self.client.application_id)
@ -906,7 +902,7 @@ class CommandTree(Generic[ClientT]):
Syncing the commands failed.
Forbidden
The client does not have the ``applications.commands`` scope in the guild.
ClientException
MissingApplicationID
The client does not have an application ID.
Returns
@ -916,7 +912,7 @@ class CommandTree(Generic[ClientT]):
"""
if self.client.application_id is None:
raise ClientException(APP_ID_NOT_FOUND)
raise MissingApplicationID
commands = self._get_all_commands(guild=guild)
payload = [command.to_dict() for command in commands]