A Discord bot for configiuring permissions declaratively in YAML.
- Declarative configuration for role permissions
- Support for mapping the same config across multiple guilds, such as a staging server
BOT_TOKEN: Required, a bot token for the Discord APIENV: A non-production environment to use, as specified in the config file. If not set, uses theproductionenvironment.
Mopbot includes a GitHub Action for use in a CI/CD deployment. Below is an example workflow.
name: Mopbot
on:
push:
branches: [ main ]
jobs:
mopbot:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Mopbot
id: bot
uses: "morpheus636/mopbot"
with:
config_file: config.yaml # (Optional, config.yaml) Name of the config file relative to the project root
check: false # (Optional, false) Validate the config file against the schema but take no action
dry_run: false # (Optional, false) Run through the config file but do not apply the changes
env:
BOT_TOKEN: "${{ secrets.BOT_TOKEN }}"
ENV: "production"usage: mopbot [-h] [-C] [-D] [file]
A declarative configuration tool for Discord servers.
positional arguments:
file The config file to use
options:
-h, --help show this help message and exit
-C, --check Validate the config file against the schema but take no
action
-D, --dry_run Run through the config file but do not apply the changes
Mopbot is configured via a YAML configuration file, the full format for which is defined via a JSON-Schema. The default configuration target is config.yaml, but this can be changed by passing a different file name or path as a command-line argument (eqivilent to the config_file input on GitHub Actions).
To make it so one configuration can be applied to muliple guilds (for example, a production server and a testing server), Mopbot uses arbitrary configuration IDs to refer to roles internally. Configuration IDs can be any string.
At runtime, configuration IDs are mapped to Discord role IDs via environment definitions, set under the top-level environments: key in the config file. Each environment definition must contain a guild_id: key containing the target Discord server ID and a roles: key, containing key-value pairs of configuration IDs and their corresponding Discord role IDs.
The default environment is called production. Other environments can be chosen by setting the ENV environment variable.
environments:
production:
guild_id: <discord_id>
roles:
role_configuration_id_1: <discord_id>
role_configuration_id_2: <discord_id>
staging:
guild_id: <discord_id>
roles:
role_configuration_id_1: <discord_id>
role_configuration_id_2: <discord_id>Roles are applied through an array of definitions under the top-level roles: key.
Each definition must include an array roles: containing configuration IDs for each role it targets.
roles:
- roles:
- role_configuration_id_1
- role_configuration_id_2
#[role options and perms...]Role definitions apply cumulatively from top to bottom, so a config file can apply general permissions and options to a group of roles in one definition, then apply additional permissions and options to a subset of those roles in a later definition.
roles:
- roles:
- role_configuration_id_1
- role_configuration_id_2
#<role options and perms...>
- roles:
- role_configuration_id_2
#<additional role options and perms...>Mopbot supports setting the certain role options as top-level keys within a definition.
roles:
- roles:
- role_configuration_id_1
- role_configuration_id_2
name: Pretty Role
color: "#88001b"
hoist: false
mentionable: falseDefault Behavior: If an option is not set explicitly by any definition, Mopbot will not modify that option.
Duplicate Behavior: If multiple definitions set the same option for a role, Mopbot will log a warning. Where there is a conflict, the state set by the bottom-most definition applies.
The following role options are supported:
name: (string)is the role's new display name.color: (string)is a 6-character hexidecimal string representing an RGB color (RRGGBB) to apply to the role. A leading#is permitted but not required.hoist: (bool)determines whether the role should be displayed separately on the Discord UI sidebar.mentionable: (bool)determines whether the role can be metioned by users who do not have themention_everyonepermission.
Mopbot supports setting permission nodes under the top-level perms: key within a definition.
roles:
- roles:
- role_configuration_id_1
perms:
read_messages: true
send_messages: trueDefault Behavior: Permission nodes that are not set explicitly by any definition will be set to false.
Duplicate Behavior: If multiple definitions set the same permission node for a role, Mopbot will log a warning. Where there is a conflict, the state set by bottom-most definition applies.
The following permission nodes are supported:
add_reactionsadministratorattach_filesban_memberschange_nicknameconnectcreate_eventscreate_expressionscreate_instant_invitecreate_pollscreate_private_threadscreate_public_threadsdeafen_membersembed_linksexternal_emojisexternal_stickerskick_membersmanage_channelsmanage_emojismanage_emojis_and_stickersmanage_eventsmanage_expressionsmanage_guildmanage_messagesmanage_nicknamesmanage_permissionsmanage_rolesmanage_threadsmanage_webhooksmention_everyonemoderate_membersmove_membersmute_memberspin_messagespriority_speakerread_message_historyread_messagesrequest_to_speaksend_messagessend_messages_in_threadssend_pollssend_tts_messagessend_voice_messagesset_voice_channel_statusspeakstreamuse_application_commandsuse_embedded_activitiesuse_external_appsuse_external_emojisuse_external_soundsuse_external_stickersuse_soundboarduse_voice_activationview_audit_logview_channelview_creator_monetization_analyticsview_guild_insights