Skip to content

Bot Configuration

Gerald Siegert edited this page Jan 27, 2021 · 1 revision

The general bot system configuration is accessible via the Geckarbot class which is available as self.bot in each class which inherits from Configurable like all plugins. The general data is loaded from config/geckarbot.json:

{
    "DISCORD_TOKEN": "",
    "SERVER_ID": 0,
    "CHAN_IDS": {
        "admin": 0,
        "debug": 0,
        "mod": 0
    },
    "ROLE_IDS": {
        "server_admin": 0,
        "bot_admin": 0,
        "mod": 0
    },
    "DEBUG_MODE": false,
    "DEBUG_USERS": [ ],
    "GOOGLE_API_KEY": "",
    "LANG": "de",
    "PLUGINS":{
        "load": [],
        "not_load": []
}

Neccessary Keys

The following keys are neccessary to use the bot:

  • DISCORD_TOKEN: The bot token provided from Discord to connect with the bot
  • SERVER_ID: The ID of the server to connect
  • CHAN_IDS: The IDs for general channels on the server:
    • admin: The channel for server admin related log messages. Will only be used to output messages if ID is a valid channel ID for the server.
    • debug: The channel for bot admin related (error) messages. Will only be used to output messages if ID is a valid channel ID for the server.
    • mod: The channel for moderation related log messages. Will only be used to output messages if ID is a valid channel ID for the server.
  • ROLE_IDS: The IDs for roles on the server, important roles are:
    • server_admin: The server admin role
    • bot_admin: The role for (main) bot manager/admin
    • mod: The role for server/bot moderation role

Note, that the same channel or role ID can also be used for multiple channels or roles.

The attributes to get the general system configuration are named like in the json file, so you can access the server id via bot.SERVER_ID for example.

Special access variables

For fast access to some special channel and role IDs, there are following additional attributes provided by the Geckarbot class and are also accessable using Config():

  • ADMIN_CHAN_ID: Channel ID for channel admin
  • DEBUG_CHAN_ID: Channel ID for channel debug
  • MOD_CHAN_ID: Channel ID for channel mod
  • SERVER_ADMIN_ROLE_ID: Role ID for role server_admin
  • BOT_ADMIN_ROLE_ID: Role ID for role bot_admin
  • MOD_ROLE_ID: Role ID for role mod
  • ADMIN_ROLES: List with role IDs for server and bot admins
  • MOD_ROLES: List with role IDs for both admin roles and also the mod role

Debugging keys

For debugging purposes there are following configuration keys:

  • DEBUG_MODE: For debugging, if true print debug output like full exception trace to console instead of a shorter version to debug channel
  • DEBUG_USERS: Only affected if DEBUG_MODE is true, provides a list of the IDs of the users, the bot should react in debug mode

Google API Key

If a plugin or command needs direct access to one of Google's APIs, the GOOGLE_API_KEY is necessary. A Key can be created at Googles Dev Console and must have access to the needed APIs like Google Sheets API. The API key can be used to get data only. For writing data OAuth credentials using a service account are neccessary, which must be saved in config/google_service_account.json.

Language Setting

To change the bots output language (as far as supported) the LANG key can be used to set the 2-letter language code like en or de.

Enable/Disable plugins on startup

To enable the loading of only specific plugins or disable it on bot startup, the lists in PLUGINS can be used. Boths lists have to be a list of strings of the names of the plugins, for example mod for the moderation plugin.

All plugins listed in load will be loaded on startup, but no other plugins. If this list is empty, all available plugins will be loaded. To prevent loading plugins on bot startup, the list not_load can be used. Entries in the not_load list are overwriting entries in the load list, so if a plugin is listed in both lists, it won't be loaded on startup.

Regardless of whether a plugin is loaded on startup or not, it can be always loaded or unloaded during runtime using the !plugin command. Note that this is for regular plugins only, core plugins, utils and subsystems can't be disabled and will be loaded on startup regardless of whether it is listed in one of the both lists.

Clone this wiki locally