Discord

Run Your Bot On Discord

The flottbot framework also supports Discord as a remote chat network.

Setup Your Discord Bot

Create your bot as an app

  1. Navigate to the Applications page
  2. Click on the New Application button
  3. Enter your bot's name on the next screen
  4. Click create the Create button on the bottom right

Add your bot to your server

  1. Navigate to the Applications page
  2. Select one of your bot applications
  3. Click on OAuth2 in the side navigation under "Settings"
  4. Check the checkbox for Bot in the "Scopes" section
  5. Copy the link it generated and navigate to it in your browser
  6. Select a server from the drop-down menu. You must have the Manage Server permission to add a bot to a server! If no servers appear, you may need to log in.

Configure Your Bot

First you will need your bot token and server id. For the bot token, follow these steps:

  1. Navigate to the Applications page
  2. Select one of your bot applications
  3. Click on Bot in the side navigation under "Settings"
  4. Use Click to Reveal Token in the "Build-A-Bot" section to see your token

To get your server id, check Discord's official knowledgebase article

Now that you have both your bot token and server id, edit the following lines in /config/bot.yml to look like:

chat_application: discord
discord_token: ${DISCORD_TOKEN}
discord_server_id: ${DISCORD_SERVER_ID}

Write some rules for your bot.

Now, you'll need to export your Discord bot token and server id values as environment variables:

export DISCORD_TOKEN=xxxxxxxxxxxxxxxxxx.xxxxxx.xxxxxxxxx.xxxxxxxxxx
export DISCORD_SERVER_ID=###############

Now run your bot using docker with the following command (make sure docker is up and running):

docker run --rm --name mybot --env DISCORD_TOKEN=$DISCORD_TOKEN --env DISCORD_SERVER_ID=$DISCORD_SERVER_ID -v "$PWD"/config:/config target/flottbot:latest /flottbot

Your bot should now be online in the Discord server where you configured your bot.