mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-18 23:15:48 +00:00
Allow getting all commands from CommandTree.get_commands
Co-authored-by: Danny <Rapptz@users.noreply.github.com>
This commit is contained in:
parent
79bd18f98c
commit
5892bbd8b4
@ -499,7 +499,7 @@ class CommandTree(Generic[ClientT]):
|
||||
self,
|
||||
*,
|
||||
guild: Optional[Snowflake] = ...,
|
||||
type: Literal[AppCommandType.chat_input] = ...,
|
||||
type: Literal[AppCommandType.chat_input],
|
||||
) -> List[Union[Command[Any, ..., Any], Group]]:
|
||||
...
|
||||
|
||||
@ -512,12 +512,25 @@ class CommandTree(Generic[ClientT]):
|
||||
) -> Union[List[Union[Command[Any, ..., Any], Group]], List[ContextMenu]]:
|
||||
...
|
||||
|
||||
@overload
|
||||
def get_commands(
|
||||
self,
|
||||
*,
|
||||
guild: Optional[Snowflake] = ...,
|
||||
type: Optional[AppCommandType] = ...,
|
||||
) -> List[Union[Command[Any, ..., Any], Group, ContextMenu]]:
|
||||
...
|
||||
|
||||
def get_commands(
|
||||
self,
|
||||
*,
|
||||
guild: Optional[Snowflake] = None,
|
||||
type: AppCommandType = AppCommandType.chat_input,
|
||||
) -> Union[List[Union[Command[Any, ..., Any], Group]], List[ContextMenu]]:
|
||||
type: Optional[AppCommandType] = None,
|
||||
) -> Union[
|
||||
List[ContextMenu],
|
||||
List[Union[Command[Any, ..., Any], Group]],
|
||||
List[Union[Command[Any, ..., Any], Group, ContextMenu]],
|
||||
]:
|
||||
"""Gets all application commands from the tree.
|
||||
|
||||
Parameters
|
||||
@ -525,15 +538,17 @@ class CommandTree(Generic[ClientT]):
|
||||
guild: Optional[:class:`~discord.abc.Snowflake`]
|
||||
The guild to get the commands from, not including global commands.
|
||||
If not given or ``None`` then only global commands are returned.
|
||||
type: :class:`~discord.AppCommandType`
|
||||
The type of commands to get. Defaults to :attr:`~discord.AppCommandType.chat_input`,
|
||||
i.e. slash commands.
|
||||
type: Optional[:class:`~discord.AppCommandType`]
|
||||
The type of commands to get. When not given or ``None``, then all
|
||||
command types are returned.
|
||||
|
||||
Returns
|
||||
---------
|
||||
Union[List[:class:`ContextMenu`], List[Union[:class:`Command`, :class:`Group`]]
|
||||
List[Union[:class:`ContextMenu`, :class:`Command`, :class:`Group`]]
|
||||
The application commands from the tree.
|
||||
"""
|
||||
if type is None:
|
||||
return self._get_all_commands(guild=guild)
|
||||
|
||||
if type is AppCommandType.chat_input:
|
||||
if guild is None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user