Browse Source

Merge 281ad1b8b1 into 26855160f8

pull/9452/merge
Soheab 4 weeks ago
committed by GitHub
parent
commit
6edda1cb30
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 16
      discord/app_commands/tree.py
  2. 17
      discord/http.py

16
discord/app_commands/tree.py

@ -200,7 +200,9 @@ class CommandTree(Generic[ClientT]):
return AppCommand(data=command, state=self._state)
async def fetch_commands(self, *, guild: Optional[Snowflake] = None) -> List[AppCommand]:
async def fetch_commands(
self, *, guild: Optional[Snowflake] = None, with_localizations: bool = False
) -> List[AppCommand]:
"""|coro|
Fetches the application's current commands.
@ -217,6 +219,10 @@ class CommandTree(Generic[ClientT]):
guild: Optional[:class:`~discord.abc.Snowflake`]
The guild to fetch the commands from. If not passed then global commands
are fetched instead.
with_localizations: :class:`bool`
Whether to fetch the localizations for the commands. Defaults to ``False``.
.. versionadded:: 2.4
Raises
-------
@ -234,9 +240,13 @@ class CommandTree(Generic[ClientT]):
raise MissingApplicationID
if guild is None:
commands = await self._http.get_global_commands(self.client.application_id)
commands = await self._http.get_global_commands(
self.client.application_id, with_localizations=with_localizations
)
else:
commands = await self._http.get_guild_commands(self.client.application_id, guild.id)
commands = await self._http.get_guild_commands(
self.client.application_id, guild.id, with_localizations=with_localizations
)
return [AppCommand(data=data, state=self._state) for data in commands]

17
discord/http.py

@ -2198,8 +2198,13 @@ class HTTPClient:
# Application commands (global)
def get_global_commands(self, application_id: Snowflake) -> Response[List[command.ApplicationCommand]]:
return self.request(Route('GET', '/applications/{application_id}/commands', application_id=application_id))
def get_global_commands(
self, application_id: Snowflake, with_localizations: bool = False
) -> Response[List[command.ApplicationCommand]]:
params = {'with_localizations': int(with_localizations)}
return self.request(
Route('GET', '/applications/{application_id}/commands', application_id=application_id), params=params
)
def get_global_command(self, application_id: Snowflake, command_id: Snowflake) -> Response[command.ApplicationCommand]:
r = Route(
@ -2254,15 +2259,19 @@ class HTTPClient:
# Application commands (guild)
def get_guild_commands(
self, application_id: Snowflake, guild_id: Snowflake
self,
application_id: Snowflake,
guild_id: Snowflake,
with_localizations: bool = False,
) -> Response[List[command.ApplicationCommand]]:
params = {'with_localizations': int(with_localizations)}
r = Route(
'GET',
'/applications/{application_id}/guilds/{guild_id}/commands',
application_id=application_id,
guild_id=guild_id,
)
return self.request(r)
return self.request(r, params=params)
def get_guild_command(
self,

Loading…
Cancel
Save