A Discord bot designed to entertain your server esmbot.net
esmBot docs config.md
5.7 kB · 95 lines
Markdown

Config #

esmBot uses a mix of environment variables and JSON for configuration.

Environment Variables (.env) #

To make managing environment variables easier, an example .env file is included with the bot at .env.example and can be used to load the variables on startup.

Required #

  • NODE_ENV: Used for tuning the bot to different environments. If you don't know what to set it to, leave it as is.
  • TOKEN: Your bot's token. You can find this in the Discord developer portal under your application's Bot tab.
  • DB: The database connection string. By default the sqlite and postgresql protocols are available, but this can be expanded by putting proper DB driver scripts into utils/database/.
  • OWNER: Your Discord user ID. This is used for granting yourself access to certain management commands. Adding multiple users is supported by separating the IDs with a comma; however, this is not recommended for security purposes.
  • PREFIX: The bot's default command prefix for classic commands. Note that servers can set their own individual prefixes via the prefix command.
  • LOCALE: The default language/locale for messages sent by the bot. A corresponding locale JSON must be present in the locales directory, and if the command is an interaction, it will be overridden by the user's set client language.

Optional #

These variables that are not necessarily required for the bot to run, but can greatly enhance its functionality:

  • STAYVC: Set this to true if you want the bot to stay in voice chat after playing music/a sound effect. You can make it leave by using the stop command.
  • KLIPY: An API token from KLIPY. This is required for parsing share links from KLIPY.
  • REST_PROXY: A Discord REST URL to use besides the default (https://discord.com/api/v{version_number}). Can be useful for proxying requests to Discord through an external server.
  • REST_TIMEOUT_MS: An amount of time in milliseconds to wait until outgoing requests to Discord are timed out. Defaults to 15000 (15 seconds).
  • OUTPUT: A directory to output the help documentation in Markdown format to. It's recommended to set this to a directory being served by a web server.
  • TEMPDIR: A directory that will store generated media files larger than Discord's filesize limit. It's recommended to set this to a directory being served by a web server.
  • TMP_DOMAIN: The root domain/directory that the media files larger than Discord's filesize limit are stored at. Example: https://projectlounge.pw/tmp
  • THRESHOLD: A filesize threshold that the bot will start deleting old files in TEMPDIR at.
  • CLUSTER_PORT: The HTTP port to serve cluster management endpoints and Prometheus-compatible metrics on.
  • API_TYPE: Set this to "none" if you want to process all media locally. Alternatively, set it to "ws" to use a media API server specified in the media block of config/servers.json.
  • ADMIN_SERVER: A Discord server/guild ID to limit owner-only commands such as eval to.
  • INTERACTIONS_PORT: The port to serve the HTTP interaction endpoints on. Both this and PUBLIC_KEY need to be set to enable the HTTP interactions server.
  • PUBLIC_KEY: Your bot's public key; setting this to a non-empty value will enable the HTTP interactions server on the port specified by INTERACTIONS_PORT. You can find this in the Discord developer portal under your application's General Information tab.

JSON #

The JSON-based configuration files are located in config/.

commands.json #

{
  "types": {
    "classic": false, // Enable/disable "classic" (prefixed) commands, note that classic commands in direct messages will still work
    "application": true // Enable/disable application commands (slash and context menu commands)
  },
  "blacklist": [
    // Names of commands that you don't want the bot to load
  ]
}

messages.json #

{
  "emotes": [
    // Discord emote strings to use in the "Processing... this may take a while" messages, e.g. "<a:processing:818243325891051581>" or "⚙️"
  ],
  "messages": [
    // Strings to use in the bot's activity message/playing status
  ]
}

servers.json #

{
  "lava": [ // Objects containing info for connecting to Lavalink audio server(s)
    {
      "name": "test", // A human-friendly name for the server
      "url": "localhost:2333", // IP address/domain name and port for the server
      "auth": "youshallnotpass" // Password/authorization code for the server
    }
  ],
  "media": [ // Objects containing info for connecting to WS media server(s)
    {
      "name": "test", // A human-friendly name for the server
      "server": "localhost", // IP address or domain name for the server
      "auth": "verycoolpass100", // Password/authorization code for the server
      "tls": false // Whether or not this is a secure TLS/wss connection
    }
  ],
  "search": [ // Objects containing metasearch server info for the search commands (image and youtube)
    {
      "type": "searxng", // Metasearch server type (can be "searxng" or "degoog")
      "url": "https://searx.projectlounge.pw", // Base HTTP/HTTPS URL for the server (instance must support getting results over JSON, degoog instances must have "Serve the SearXNG API shape" enabled)
      "engines": ["google cse images", "startpage images"], // List of image search engine source IDs to query from (searxng only, check instance preferences page)
      "ytBang": "!youtube_noapi" // Search command/bang to use for YouTube results (degoog only, check available bangs in admin interface or by searching !help)
    }
  ]
}