A Discord bot to help play the Fate roleplaying game.
Once Discord Fate Bot is invited to a server, it will listen in text channels
for commands and reply. All commands start with !
.
Roll four Fate dice, with modifiers, optionally against a static opposition. This command has the following forms.
!roll
— Simply roll four Fate dice and see the result!roll [+|-]MOD...
— Roll with a modifier. The+
or-
is required. Multiple modifiers may be given, separated by spaces.- Example:
!roll +5 -2
to roll with an effective +3 modifier.
- Example:
!roll MODIFIERS vs OPPOSITION
— Roll against a static opposition amount. The result will be one of: fail, tie, succeed, or succeed with style.- Example:
!roll +2 vs 3
- Example:
Start a scene in the current channel. Each channel can have one scene active, which can be used to track situation aspects. The message describing the current scene will automatically be pinned (and unpinned when the scene ends).
-
!scene [DESCRIPTION]
— Start a new scene in the current channel. The entire rest of the message will be used as the description. If a scene is already active, it will be ended automatically.- Example:
!scene Warehouse Five
- Example:
-
!scene end
— End the current scene.
Add or manage aspects in the current scene. There must be an active scene in the current channel to use these commands. Aspects are automatically added to the pinned scene message.
Every aspect is given an ID — a unique number within the scene — which is used to refer to the aspect after creation (for example, to remove it).
!aspect NAME
— Add a new aspect to the current scene. The rest of the line will be used the aspect name.- Example:
!aspect Darkness of night
- Example:
!aspect remove ID...
— Remove one or more aspects from the scene.!aspect rename ID [NAME]
— Rename an existing aspect. The rest of the line will be used as the new aspect name.- Example:
!aspect modify 2 New aspect name
- Example:
Add or manage boosts in the current scene. All the rules from !aspect
apply
for this command as well. Note that boosts are still aspects, so they can be
manipulated with !aspect remove
and !aspect rename
.
!boost NAME
— Add a new boost to the current scene. The rest of the line will be used the aspect name. Boosts are always created with one free invoke.- Example:
!boost Slippery banana peel
- Example:
!boost upgrade ID [NAME]
— Upgrade a boost to a full aspect, optionally renaming it in the process. The rest of the line, if any, will be used the new aspect name.!boost downgrade ID [NAME]
— Upgrade an existing aspect to a boost, optionally renaming it in the process. The rest of the line, if any, will be used the new aspect name.
!invoke ID
— Decrease the number of remaining free invokes for the specified aspect.- Example:
!invoke 3
to remove a free invoke from Aspect #3. - TODO: If and when we introduce a Fate Point tracker, we will likely have this command tie in, so that an aspect can be invoked for a Fate Point.
- Example:
!invoke add [[+|-]AMOUNT] ID
— Add (or remove) a number of free invokes from the specified aspect. The amount is optional (the default is+1
), but it must start with+
or-
.- Example:
!invoke add 2
to add one free invoke to Aspect #2. - Example:
!invoke add +2 1
to add two free invokes to Aspect #1. - Example:
!invoke add -1 3
to remove one free invoke from Aspect #3.
- Example:
I plan to add commands to manage a turn order, and possibly to track fate points. Beyond that, I may add facilities to track PCs and NPCs, though Discord text channels may not be the most convenient interface to manage those.
There isn't currently a public instance of Discord Fate Bot available for invite. If you host your own copy, the bot will log an invite URL when it connects to Discord. Currently, the bot will ask for the following Discord permissions.
- Add reactions
- To leave a 👍 once it has processed a message.
- Manage messages
- To pin and unpin the scene message.
- Read message history
- Not currently used, but I have a half-thought that there could be a feature to recover scenes from message history if the database is out-of-sync with the channel.
- Read messages
- To read commands.
- Send messages
- To reply with results.
This list may grow and change while the bot is in development, but I'll try to freeze it once I release a stable public version.
This is the approach I'm currently using. Docker App is currently an experimental plugin for Docker for deploying application bundles in Docker Swarm. The bundles are uploaded as images right in Docker Hub, and the service images are baked right into the application bundle.
The app for Discord Fate Bot defines two services, one for the bot itself, and one for a MongoDB database. The latter will only be replicated to the swarm manager, and the database will be saved in a Docker volume.
To install as an App, first install Docker App. It's a CLI extension, so you just need it on the machine where you're managing the swarm.
Next, set up the necessary secrets to run the app.
$ docker secret create discord-fate-bot-token -
$ docker secret create discord-fate-bot-mongo-password -
Each command will wait for you to type input on standard input (end with Ctrl-D
on a new line). Alternately, you can pipe in the secret or supply a filename in
place of -
.
Finally, install the app itself.
$ docker app install chrisbouchard/discord-fate-bot-app
Creating network discord-fate-bot-app_internal
Creating service discord-fate-bot-app_app
Creating service discord-fate-bot-app_mongo
Application "discord-fate-bot-app" installed on context "default"
Using the default name, the services created will be discord-fate-bot-app_app
for the bot service, and discord-fate-bot-app_mongo
for the MongoDB service.
You can use the standard Docker Swarm tools to manage them, e.g., docker service logs
to view logs.
When a new version of Discord Fate Bot is released, you can update your application to the latest version as so.
$ docker app upgrade discord-fate-bot-app --app-name=chrisbouchard/discord-fate-bot-app
Updating service discord-fate-bot-app_app (id: ...)
Updating service discord-fate-bot-app_mongo (id: ...)
Application "discord-fate-bot-app" upgraded on context "default"
Discord Fate Bot is also available on PyPI.
$ pip install discord-fate-bot
$ discord-fate-bot
Make sure to configure your environment variables to hook up to Discord and your Mongo database (see below).
I don't necessarily recommend this for production, but you can check out the project locally and install in a virtual environment.
Make sure you have at least Python 3.7 installed. You'll also need to install Poetry, which we use for dependency management and packaging.
$ git checkout https://github.com/chrisbouchard/discord-fate-bot.git
$ cd discord-fate-bot
$ poetry install
$ poetry run discord-fate-bot
Make sure to configure your environment variables to hook up to Discord and your Mongo database (see below).
Discord Fate Bot looks for the following environment variables on start-up.
DFB_BOT_TOKEN
— The Discord authentication token for the bot account.- Mutually exclusive with
DFB_BOT_TOKEN_FILE
.
- Mutually exclusive with
DFB_BOT_TOKEN_FILE
— The path to a file containing the authentication token.- Mutually exclusive with
DFB_BOT_TOKEN
.
- Mutually exclusive with
DFB_LOG_CONFIG_FILE
— (Optional) The path to a Python log config file. See the Python documentation for a description of the file format.DFB_MONGO_CONNECTION_URL
— The MongoDB connection URL.DFB_MONGO_PASSWORD
— The password for the Mongo DB connection.- Mutually exclusive with
DFB_MONGO_PASSWORD_FILE
.
- Mutually exclusive with
DFB_MONGO_PASSWORD_FILE
— The path to a file containing the password for the Mongo DB connection.- Mutually exclusive with
DFB_MONGO_PASSWORD
.
- Mutually exclusive with
Note: For variables that have a *_FILE
pair, the direct version is
provided as a convenience, e.g., for development. I subscribe to the school of
thought that it's best not to store production secrets in environment variables
if at all avoidable. Our Docker Stack definition uses Secrets to share the
Discord token and Mongo password into the services.
Discord Fate Bot is written in Python, mostly based on the awesome Discord.py library. We use MongoDB for long-term storage when necessary (e.g., for scenes and aspects).