API Reference

Syntax class

class discord.ext.syntaxer.Syntax(command: discord.ext.commands.core.Command, description: Optional[str] = None, *, default_format: str = '{prefix}{variable_prefix}{command_name}{variable_suffix}{suffix}', kwarg_format: str = '{prefix}{variable_prefix}{command_name}{variable_suffix}', required_formats: Tuple[str, str] = ('<', '>'), optional_formats: Tuple[str, str] = ('[', ']'), variable_formats: Tuple[str, str] = ('', '...'))

Analyze command and make Syntax object.

This inherits SpaceList, so :func:str will return a formatted syntax.

Parameters
  • command (commands.Command) – Command to analyze syntax.

  • description (str, optional) – Description of the command. If None, use docstring.

  • default_format (str, optional) – Format of regular argument, by default “{prefix}{variable_prefix}{command_name}{variable_suffix}{suffix}”

  • kwarg_format (str, optional) – Format of keyword argument, by default “{prefix}{variable_prefix}{command_name}{variable_suffix}”

  • required_formats (tuple, optional) – Prefix and suffix of required argument, by default (“<”, “>”)

  • optional_formats (tuple, optional) – Prefix and suffix of optional argument, by default (“[“, “]”)

  • variable_formats (tuple, optional) – Prefix and suffix of variable argument, by default (“”, “…”)

property args

Returns SpaceList with command arguments.

property names

Return SpaceList with command name and parents.

Syntax elements

class discord.ext.syntaxer.CommandName(name: str, parent: Optional[discord.ext.syntaxer.main.ParentName] = None)

Represents name of a command.

Parameters
  • name (str) – Name of the command.

  • parent (ParentName) – Parent of the command, None if the command doesn’t have a parent.

class discord.ext.syntaxer.CommandArgument(name: str, required: bool, description: str, formatted: str, flag: discord.ext.syntaxer.main.ArgumentType, default: Any, param: inspect.Parameter)

Represents a command argument.

str returns formatted value.

Parameters
  • name (str) – Name of the argument.

  • required (bool) – The argument is required or optional.

  • description (str) – Description of the argument.

  • formatted (str) – Formatted value for the argument.

  • flag (int) – Type flag of the argument.

  • default (Optional[Any]) – Default value of the argument if any.

  • param (:class:inspect.Parameter) – Parameter for the argument.

property optional

Same as not self.required.

Other classes

class discord.ext.syntaxer.SpaceList(iterable=(), /)

A special list. When you pass this list to str, content will be converted with :func:str, and joins them with space.