Browse Source

Document a couple things

pull/10109/head
dolfies 3 years ago
parent
commit
895b374339
  1. 68
      discord/commands.py

68
discord/commands.py

@ -37,9 +37,43 @@ if TYPE_CHECKING:
from .message import Message from .message import Message
from .state import ConnectionState from .state import ConnectionState
__all__ = (
'ApplicationCommand',
'BaseCommand',
'UserCommand',
'MessageCommand',
'SlashCommand',
'SubCommand',
'Option',
'OptionChoice',
)
@runtime_checkable @runtime_checkable
class ApplicationCommand(Protocol): class ApplicationCommand(Protocol):
"""An ABC that represents a useable application command.
The following implement this ABC:
- :class:`~discord.BaseCommand`
- :class:`~discord.UserCommand`
- :class:`~discord.MessageCommand`
- :class:`~discord.SlashCommand`
- :class:`~discord.SubCommand`
Attributes
-----------
name: :class:`str`
The command's name.
description: :class:`str`
The command's description, if any.
version: :class:`int`
The command's version.
type: :class:`CommandType`
The type of application command.
default_permission: :class:`bool`
Whether the command is enabled in guilds by default.
"""
__slots__ = () __slots__ = ()
@ -84,6 +118,23 @@ class ApplicationCommand(Protocol):
class BaseCommand(ApplicationCommand): class BaseCommand(ApplicationCommand):
"""Represents a base command.
Attributes
----------
id: :class:`int`
The command's ID.
name: :class:`str`
The command's name.
description: :class:`str`
The command's description, if any.
version: :class:`int`
The command's version.
type: :class:`CommandType`
The type of application command.
default_permission: :class:`bool`
Whether the command is enabled in guilds by default.
"""
__slots__ = ( __slots__ = (
'name', 'name',
@ -222,21 +273,7 @@ class SlashMixin(ApplicationCommand):
class UserCommand(BaseCommand): class UserCommand(BaseCommand):
"""Represents a user command. """Represents a user command."""
Attributes
----------
id: :class:`int`
The command's ID.
name: :class:`str`
The command's name.
description: :class:`str`
The command's description, if any.
type: :class:`CommandType`
The type of application command. Always :class:`CommandType.user`.
default_permission: :class:`bool`
Whether the command is enabled in guilds by default.
"""
__slots__ = ('_user',) __slots__ = ('_user',)
@ -558,6 +595,7 @@ class SubCommand(SlashMixin):
def target_channel(self, value: Optional[Messageable]) -> None: def target_channel(self, value: Optional[Messageable]) -> None:
self._parent.target_channel = value self._parent.target_channel = value
class Option: class Option:
"""Represents a command option. """Represents a command option.

Loading…
Cancel
Save