curious.commands.decorators

Decorators to annotate function objects.

Functions

autoplugin([plugin, startswith]) Automatically assigns commands inside a plugin.
command(*[, name, description, hidden, aliases]) Marks a function as a command.
condition(cbl) Adds a condition to a command.
ratelimit(*, limit, time[, bucket_namer]) Adds a ratelimit to a command.
curious.commands.decorators._subcommand(parent)[source]

Decorator factory set on a command to produce subcommands.

curious.commands.decorators.autoplugin(plugin=None, *, startswith='command')[source]

Automatically assigns commands inside a plugin.

This will scan a Plugin for functions matching the pattern command_[parent_]name, and automatically decorate them with the command decorator and subcommand decorators.

Parameters:
  • plugin (Optional[Type[Plugin]]) – The Plugin subclass to autoplugin.
  • startswith (str) – Used to override what the command function prefix will be.
Return type:

Type[Plugin]

Returns:

The edited plugin.

curious.commands.decorators.command(*, name=None, description=None, hidden=False, aliases=None, **kwargs)[source]

Marks a function as a command. This annotates the command with some attributes that allow it to be invoked as a command.

This decorator can be invoked like this:

@command()
async def ping(self, ctx):
    await ctx.channel.messages.send("Ping!")
Parameters:
  • name (Optional[str]) – The name of the command. If this is not specified, it will use the name of the function object.
  • description (Optional[str]) – The description of the command. If this is not specified, it will use the first line of the docstring.
  • hidden (bool) – If this command is hidden; i.e. it doesn’t show up in the help listing.
  • aliases (Optional[List[str]]) – A list of aliases for this command.
  • kwargs – Anything to annotate the command with.
curious.commands.decorators.condition(cbl)[source]

Adds a condition to a command.

This will add the callable to cmd_conditions on the function.

curious.commands.decorators.ratelimit(*, limit, time, bucket_namer=<function BucketNamer.AUTHOR>)[source]

Adds a ratelimit to a command.