docstrings, *args, and error changes
This commit is contained in:
parent
7bf90f9e27
commit
8a779ef595
@ -615,6 +615,8 @@ class Client:
|
||||
|
||||
To perform asynchronous setup after the bot is logged in but before
|
||||
it has connected to the Websocket, overwrite this coroutine.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
"""
|
||||
pass
|
||||
|
||||
@ -706,7 +708,7 @@ class Client:
|
||||
""":class:`.Status`:
|
||||
The status being used upon logging on to Discord.
|
||||
|
||||
.. versionadded: 2.0
|
||||
.. versionadded:: 2.0
|
||||
"""
|
||||
if self._connection._status in set(state.value for state in Status):
|
||||
return Status(self._connection._status)
|
||||
|
@ -1128,6 +1128,24 @@ class BotBase(GroupMixin):
|
||||
|
||||
|
||||
async def process_slash_commands(self, interaction: discord.Interaction):
|
||||
"""|coro|
|
||||
|
||||
This function processes a slash command interaction into a usable
|
||||
message and calls :meth:`.process_commands` based on it. Without this
|
||||
coroutine slash commands will not be triggered.
|
||||
|
||||
By default, this coroutine is called inside the :func:`.on_interaction`
|
||||
event. If you choose to override the :func:`.on_interaction` event,
|
||||
then you should invoke this coroutine as well.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
Parameters
|
||||
-----------
|
||||
interaction: :class:`discord.Interaction`
|
||||
The interaction to process slash commands for.
|
||||
|
||||
"""
|
||||
interaction.data = cast(ApplicationCommandInteractionData, interaction.data)
|
||||
command_name, command_options = _unwrap_slash_groups(interaction.data)
|
||||
|
||||
@ -1164,7 +1182,6 @@ class BotBase(GroupMixin):
|
||||
raise errors.MissingRequiredArgument(param)
|
||||
elif (
|
||||
option["type"] == 3
|
||||
and " " in option["value"] # type: ignore
|
||||
and param.kind != param.KEYWORD_ONLY
|
||||
and not isinstance(param.annotation, Greedy)
|
||||
):
|
||||
|
@ -586,7 +586,7 @@ class ThreadConverter(IDConverter[discord.Thread]):
|
||||
2. Lookup by mention.
|
||||
3. Lookup by name.
|
||||
|
||||
.. versionadded: 2.0
|
||||
.. versionadded:: 2.0
|
||||
"""
|
||||
|
||||
async def convert(self, ctx: Context, argument: str) -> discord.Thread:
|
||||
|
@ -1187,7 +1187,7 @@ class Command(_BaseCommand, Generic[CogT, P, T]):
|
||||
if self.slash_command is False:
|
||||
return
|
||||
elif nested == 3:
|
||||
raise ValueError(f"{self.qualified_name} is too deeply nested!")
|
||||
raise ApplicationCommandRegistrationError(self, f"{self.qualified_name} is too deeply nested!")
|
||||
|
||||
payload = {
|
||||
"name": self.name,
|
||||
@ -1208,7 +1208,7 @@ class Command(_BaseCommand, Generic[CogT, P, T]):
|
||||
option: Dict[str, Any] = {
|
||||
"name": name,
|
||||
"description": self.option_descriptions[name],
|
||||
"required": param.default is param.empty and not self._is_typing_optional(annotation),
|
||||
"required": (param.default is param.empty and not self._is_typing_optional(annotation)) or param.kind == param.VAR_POSITIONAL,
|
||||
}
|
||||
|
||||
annotation = cast(Any, annotation)
|
||||
@ -1616,7 +1616,7 @@ class Group(GroupMixin[CogT], Command[CogT, P, T]):
|
||||
if self.slash_command is False:
|
||||
return
|
||||
elif nested == 2:
|
||||
raise ValueError(f"{self.qualified_name} is too deeply nested for slash commands!")
|
||||
raise ApplicationCommandRegistrationError(self, f"{self.qualified_name} is too deeply nested!")
|
||||
|
||||
return { # type: ignore
|
||||
"name": self.name,
|
||||
|
@ -930,9 +930,9 @@ class ApplicationCommandRegistrationError(ClientException):
|
||||
command: :class:`Command`
|
||||
The command that failed to be converted.
|
||||
"""
|
||||
def __init__(self, command: Command) -> None:
|
||||
def __init__(self, command: Command, msg: str = None) -> None:
|
||||
self.command = command
|
||||
super().__init__(f"{command.qualified_name} failed to converted to an application command.")
|
||||
super().__init__(msg or f"{command.qualified_name} failed to converted to an application command.")
|
||||
|
||||
class FlagError(BadArgument):
|
||||
"""The base exception type for all flag parsing related errors.
|
||||
|
Loading…
x
Reference in New Issue
Block a user