Browse Source

Properly document ApplicationCommand.__call__()

pull/10109/head
dolfies 2 years ago
parent
commit
be9fb6af74
  1. 28
      discord/commands.py
  2. 8
      docs/api.rst

28
discord/commands.py

@ -359,8 +359,6 @@ class UserCommand(BaseCommand):
guild_id: Optional[:class:`int`] guild_id: Optional[:class:`int`]
The ID of the guild this command is registered in. A value of ``None`` The ID of the guild this command is registered in. A value of ``None``
denotes that it is a global command. denotes that it is a global command.
.. automethod:: __call__
""" """
__slots__ = ('_user',) __slots__ = ('_user',)
@ -380,6 +378,11 @@ class UserCommand(BaseCommand):
channel: Optional[:class:`abc.Messageable`] channel: Optional[:class:`abc.Messageable`]
The channel to use the command on. Overrides :attr:`target_channel`. The channel to use the command on. Overrides :attr:`target_channel`.
Required if :attr:`target_channel` is not set. Required if :attr:`target_channel` is not set.
Returns
-------
:class:`Interaction`
The interaction that was created.
""" """
user = user or self._user user = user or self._user
if user is None: if user is None:
@ -464,8 +467,6 @@ class MessageCommand(BaseCommand):
guild_id: Optional[:class:`int`] guild_id: Optional[:class:`int`]
The ID of the guild this command is registered in. A value of ``None`` The ID of the guild this command is registered in. A value of ``None``
denotes that it is a global command. denotes that it is a global command.
.. automethod:: __call__
""" """
__slots__ = ('_message',) __slots__ = ('_message',)
@ -485,6 +486,11 @@ class MessageCommand(BaseCommand):
channel: Optional[:class:`abc.Messageable`] channel: Optional[:class:`abc.Messageable`]
The channel to use the command on. Overrides :attr:`target_channel`. The channel to use the command on. Overrides :attr:`target_channel`.
Required if :attr:`target_channel` is not set. Required if :attr:`target_channel` is not set.
Returns
-------
:class:`Interaction`
The interaction that was created.
""" """
message = message or self._message message = message or self._message
if message is None: if message is None:
@ -574,8 +580,6 @@ class SlashCommand(BaseCommand, SlashMixin):
The command's options. The command's options.
children: List[:class:`SubCommand`] children: List[:class:`SubCommand`]
The command's subcommands. If a command has subcommands, it is a group and cannot be used. The command's subcommands. If a command has subcommands, it is a group and cannot be used.
.. automethod:: __call__
""" """
__slots__ = ('_parent', 'options', 'children') __slots__ = ('_parent', 'options', 'children')
@ -601,6 +605,11 @@ class SlashCommand(BaseCommand, SlashMixin):
------ ------
TypeError TypeError
Attempted to use a group. Attempted to use a group.
Returns
-------
:class:`Interaction`
The interaction that was created.
""" """
if self.is_group(): if self.is_group():
raise TypeError('Cannot use a group') raise TypeError('Cannot use a group')
@ -653,8 +662,6 @@ class SubCommand(SlashMixin):
The subcommand's options. The subcommand's options.
children: List[:class:`SubCommand`] children: List[:class:`SubCommand`]
The subcommand's subcommands. If a subcommand has subcommands, it is a group and cannot be used. The subcommand's subcommands. If a subcommand has subcommands, it is a group and cannot be used.
.. automethod:: __call__
""" """
__slots__ = ( __slots__ = (
@ -705,6 +712,11 @@ class SubCommand(SlashMixin):
------ ------
TypeError TypeError
Attempted to use a group. Attempted to use a group.
Returns
-------
:class:`Interaction`
The interaction that was created.
""" """
if self.is_group(): if self.is_group():
raise TypeError('Cannot use a group') raise TypeError('Cannot use a group')

8
docs/api.rst

@ -6639,24 +6639,32 @@ ApplicationCommand
:members: :members:
:inherited-members: :inherited-members:
.. automethod:: __call__
.. attributetable:: MessageCommand .. attributetable:: MessageCommand
.. autoclass:: MessageCommand() .. autoclass:: MessageCommand()
:members: :members:
:inherited-members: :inherited-members:
.. automethod:: __call__
.. attributetable:: SlashCommand .. attributetable:: SlashCommand
.. autoclass:: SlashCommand() .. autoclass:: SlashCommand()
:members: :members:
:inherited-members: :inherited-members:
.. automethod:: __call__
.. attributetable:: SubCommand .. attributetable:: SubCommand
.. autoclass:: SubCommand() .. autoclass:: SubCommand()
:members: :members:
:inherited-members: :inherited-members:
.. automethod:: __call__
.. attributetable:: Option .. attributetable:: Option
.. autoclass:: Option() .. autoclass:: Option()

Loading…
Cancel
Save