mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-08 04:38:42 +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,
|
self,
|
||||||
*,
|
*,
|
||||||
guild: Optional[Snowflake] = ...,
|
guild: Optional[Snowflake] = ...,
|
||||||
type: Literal[AppCommandType.chat_input] = ...,
|
type: Literal[AppCommandType.chat_input],
|
||||||
) -> List[Union[Command[Any, ..., Any], Group]]:
|
) -> List[Union[Command[Any, ..., Any], Group]]:
|
||||||
...
|
...
|
||||||
|
|
||||||
@ -512,12 +512,25 @@ class CommandTree(Generic[ClientT]):
|
|||||||
) -> Union[List[Union[Command[Any, ..., Any], Group]], List[ContextMenu]]:
|
) -> 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(
|
def get_commands(
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
guild: Optional[Snowflake] = None,
|
guild: Optional[Snowflake] = None,
|
||||||
type: AppCommandType = AppCommandType.chat_input,
|
type: Optional[AppCommandType] = None,
|
||||||
) -> Union[List[Union[Command[Any, ..., Any], Group]], List[ContextMenu]]:
|
) -> Union[
|
||||||
|
List[ContextMenu],
|
||||||
|
List[Union[Command[Any, ..., Any], Group]],
|
||||||
|
List[Union[Command[Any, ..., Any], Group, ContextMenu]],
|
||||||
|
]:
|
||||||
"""Gets all application commands from the tree.
|
"""Gets all application commands from the tree.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
@ -525,15 +538,17 @@ class CommandTree(Generic[ClientT]):
|
|||||||
guild: Optional[:class:`~discord.abc.Snowflake`]
|
guild: Optional[:class:`~discord.abc.Snowflake`]
|
||||||
The guild to get the commands from, not including global commands.
|
The guild to get the commands from, not including global commands.
|
||||||
If not given or ``None`` then only global commands are returned.
|
If not given or ``None`` then only global commands are returned.
|
||||||
type: :class:`~discord.AppCommandType`
|
type: Optional[:class:`~discord.AppCommandType`]
|
||||||
The type of commands to get. Defaults to :attr:`~discord.AppCommandType.chat_input`,
|
The type of commands to get. When not given or ``None``, then all
|
||||||
i.e. slash commands.
|
command types are returned.
|
||||||
|
|
||||||
Returns
|
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.
|
The application commands from the tree.
|
||||||
"""
|
"""
|
||||||
|
if type is None:
|
||||||
|
return self._get_all_commands(guild=guild)
|
||||||
|
|
||||||
if type is AppCommandType.chat_input:
|
if type is AppCommandType.chat_input:
|
||||||
if guild is None:
|
if guild is None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user