disco.bot.command
Constants
{'type': 'assign', 'targets': ['ARGS_REGEX'], 'value': '(?: ((?:\n|.)*)$|$)'}
{'type': 'assign', 'targets': ['ARGS_UNGROUPED_REGEX'], 'value': '(?: (?:\n|.)*$|$)'}
SPLIT_SPACES_NO_QUOTE = compile(["|\']([^"\']+)["|\']|(\S+))
USER_MENTION_RE = compile(<@!?([0-9]+)>)
ROLE_MENTION_RE = compile(<@&([0-9]+)>)
CHANNEL_MENTION_RE = compile(<#([0-9]+)>)
CommandLevels = Enum(
DEFAULT = 0,
TRUSTED = 10,
MOD = 50,
ADMIN = 100,
OWNER = 500)
Classes
PluginArgumentParser
Inherits From ArgumentParser
Functions
error(self, message)
CommandEvent
An event which is created when a command is triggered. Contains information about the message, command, and parsed arguments (along with shortcuts to message information).
Attributes
Name | Type | Description |
---|---|---|
command | :class:`Command` |
The command this event was created for (aka the triggered command). |
msg | :class:`disco.types.message.Message` |
The message object which triggered this command. |
match | :class:`re.MatchObject` |
The regex match object for the command. |
name | str |
The command name (or alias) which was triggered by the command |
args | list(str) |
Arguments passed to the command |
Functions
init(self, command, msg, match)
codeblock(self
)
member(self
)
Guild member (if relevant) for the user that created the message.
channel(self
)
Channel the message was created in.
guild(self
)
Guild (if relevant) the message was created in.
author(self
)
Author of the message.
CommandError
Inherits From Exception
An exception which is thrown when the arguments for a command are invalid, or don't match the command's specifications.
Functions
init(self, msg)
Command
An object which defines and handles the triggering of a function based on user input (aka a command).
Attributes
Name | Type | Description |
---|---|---|
plugin | :class:`disco.bot.plugin.Plugin` |
The plugin this command is a member of. |
func | function |
The function which is called when this command is triggered. |
trigger | str |
The primary trigger (aka name). |
args | Optional[str] |
The argument format specification. |
aliases | Optional[list(str)] |
List of trigger aliases. |
group | Optional[str] |
The group this command is a member of. |
is_regex | Optional[bool] |
Whether the triggers for this command should be treated as raw regex. |
Functions
init(self, plugin, func, trigger,*args,**kwargs)
name(self
)
call(self,*args,**kwargs
)
get_docstring(self
)
update(self, args, level=None, aliases=None, group=None, is_regex=None, oob=False, context=None, parser=False,**kwargs)
mention_type(getters, reg, user=False, allow_plain=False)
compiled_regex(self
)
A compiled version of this command's regex.
regex(self, grouped)
The regex string that defines/triggers this command.
execute(self, event)
Handles the execution of this command given a :class:CommandEvent
Returns
Whether this command was successful