Inherits From Config

An object which is used to configure and define the runtime configuration for a bot.

Name Type Description
levels dict(snowflake, str) Mapping of user IDs/role IDs to :class:`disco.bot.commands.CommandLevesls` which is used for the default commands_level_getter.
plugins list[string] List of plugin modules to load.
commands_enabled bool Whether this bot instance should utilize command parsing. Generally this should be true, unless your bot is only handling events and has no user interaction.
commands_require_mention bool Whether messages must mention the bot to be considered for command parsing.
commands_mention_rules dict(str, bool) A dictionary describing what mention types can be considered a mention of the bot when using :attr:`commands_require_mention`. This dictionary can contain the following keys: `here`, `everyone`, `role`, `user`. When a keys value is set to true, the mention type will be considered for command parsing.
commands_prefix str A string prefix that is required for a message to be considered for command parsing.
commands_allow_edit bool If true, the bot will reparse an edited message if it was the last sent message in a channel, and did not previously trigger a command. This is helpful for allowing edits to typod commands.
commands_level_getter function If set, a function which when given a GuildMember or User, returns the relevant :class:`disco.bot.commands.CommandLevels`.
commands_group_abbrev function If true, command groups may be abbreviated to the least common variation. E.g. the grouping 'test' may be abbreviated down to 't', unless 'tag' exists, in which case it may be abbreviated down to 'te'.
plugin_config_provider Optional[function] If set, this function will replace the default configuration loading function, which normally attempts to load a file located at config/plugin_name.fmt where fmt is the plugin_config_format. The function here should return a valid configuration object which the plugin understands.
plugin_config_format str The serialization format plugin configuration files are in.
plugin_config_dir str The directory plugin configuration is located within.
http_enabled bool Whether to enable the built-in Flask server which allows plugins to handle and route HTTP requests.
http_host str The host string for the HTTP Flask server (if enabled)
http_port int The port for the HTTP Flask server (if enabled)


Inherits From LoggingClass

Disco's implementation of a simple but extendable Discord bot. Bots consist of a set of plugins, and a Disco client.

Name Type Description
client :class:`disco.client.Client` The client this bot should utilize for its connection.
config Optional[:class:`BotConfig`] The configuration to use for this bot. If not provided will use the defaults inside of :class:`BotConfig`.
Name Type Description
client `disco.client.Client` The client instance for this bot.
config `BotConfig` The bot configuration instance for this bot.
plugins dict(str, :class:`disco.bot.plugin.Plugin`) Any plugins this bot has loaded


init(self, client, config)


Creates a new instance of the bot using the utilities inside of the :mod:disco.cli module. Allows passing in a set of uninitialized plugin classes to load.

Name Type Description
plugins Optional[list(:class:`disco.bot.plugin.Plugin`)] Any plugins to load after creating the new bot instance


Generator of all commands this bots plugins have defined.


Called when a plugin is loaded/unloaded to recompute internal state.

compute_group_abbrev(self, groups)

Computes all possible abbreviations for a command grouping.


Computes a single regex which matches all possible command combinations.

get_commands_for_message(self, require_mention, mention_rules, prefix, msg)

Generator of all commands that a given message object triggers, based on the bots plugins and configuration.


tuple(:class:disco.bot.command.Command, re.MatchObject) All commands the message triggers

Name Type Description
msg :class:`disco.types.message.Message` The message object to parse and find matching commands for

get_level(self, actor)

check_command_permissions(self, command, msg)

handle_message(self, msg)

Attempts to handle a newly created or edited message in the context of command parsing/triggering. Calls all relevant commands the message triggers.

whether any commands where successfully triggered by the message
Name Type Description
msg :class:`disco.types.message.Message` The newly created or updated message object to parse/handle.

on_message_create(self, event)

on_message_update(self, event)

add_plugin(self, inst, config, ctx=None)

Adds and loads a plugin, based on its class.

Name Type Description
inst subclass (or instance therein) of `disco.bot.plugin.Plugin` Plugin class to initialize and load.
config Optional The configuration to load the plugin with.
ctx Optional[dict] Context (previous state) to pass the plugin. Usually used along w/ unload.

rmv_plugin(self, cls)

Unloads and removes a plugin based on its class.

Name Type Description
cls subclass of :class:`disco.bot.plugin.Plugin` Plugin class to unload and remove.

reload_plugin(self, cls)

Reloads a plugin.


Runs this bots core loop forever.

add_plugin_module(self, path, config)

Adds and loads a plugin, based on its module path.

load_plugin_config(self, cls)

results matching ""

    No results matching ""