Configuration

Errbot

The configuration requirements for the Discord backend are quite simple. Set the BACKEND to Discord and fill in BOT_IDENTITY dictionary.

BACKEND = "Discord"

BOT_IDENTITY = {
    "token": "<bot_token>",
    "initial_intents": "<initial_intent_state>"
    "intents": []
}
Bot Identity fields

Key

Type

Description

token

string

The bot token (generated by you on the Discord application web page.)

initial_intents

string

Initialise the intents with 'None' (no intents enabled), 'default' (all non-privileged intents) or 'all' (all intents)

intents

list or integer

Gateway Intents to be enabled for the bot.

Gateway Intents

Intents are used to inform Discord what events errbot would like to receive. If the correct permissions have been granted, the connection will be accepted and events will start to be sent to errbot. More information on intents can be seen here.

Intents identification

Integer value

String value

1

guilds

2

members

4

bans

8

emojis

16

integrations

32

webhooks

64

invites

128

voice_states

256

presences

512

guild_messages

4096

dm_messages

1024

guild_reactions

8192

dm_reactions

2048

guild_typing

16384

dm_typing

32768

message_content

65536

guild_scheduled_events

3145728

auto_moderation

1048576

auto_moderation_configuration

2097152

auto_moderation_execution

Errbot configuration accepts intents as additive or subtractive values. If an intent is prefixed with - it indicates the intent should be disabled. Unprefixed intents are considered additive and will be enabled:

List form Intents can be expressed as a list of integers, list of strings or a mixture. e.g. to enable guilds, bans and integrations:

BOT_IDENTITY = {
    "initial_intents": "none",
    "intents": [1, 4, 16]
}
BOT_IDENTITY = {
    "initial_intents": "none",
    "intents": ["guilds", "bans", 16]
}
BOT_IDENTITY = {
    "initial_intents": "none",
    "intents": [21]
}

Warning

Integer form accepts values of single or multiple intents. Be careful configuring the correct values. If in doubt, only use string form to avoid confusion.

Integer form: Intents can be expressed as a single integer which is the sum of intents to be enabled. e.g. to enable dm_typing (16384) and dm_message (4096) the sum of 16384 + 4096 = 20480, so the intent integer is 20480.

BOT_IDENTITY = {
    "initial_intents": "none",
    "intents": 20480
}

The inverse can be applied by setting all intents and applying -20480

BOT_IDENTITY = {
    "initial_intents": "all",
    "intents": -20480
}

Discord

Discord API terms of use can evolve at any point in time. Fortunately, the team that provides the discord module does a great job at insulating errbot from a lot of these subtle changes. However, there are changes that are significant enough to require extra steps to get errbot to work as desired with discord.

Gateway Intents

Enable Server members intent and Message content intent for your bot on the Discord website. See privileged-intents page for the required steps.

Warning

Security is not a one size fits all problem. The above intent settings are provided as help but you are ultimately responsible for understanding and applying the correct intents for your bot and environment. Also be aware that Discord intents change what data is sent to the bot that can affect functionality, check and test your settings well.

Since message content has become a privileged intent, unverified bots must have message content enabled from the Discord application web page. If the errbot instance is in more than 100 servers (guilds), you must apply for the bot to be verified.

There have been workarounds suggested but don’t fit will with errbot’s operating architecture. At best, they can work in a limited capacity and at worst are not supported at all nor will support be added. If this is a problem for you, you’ll need to re-evaluate your use of errbot or consider changing chat platform.

Discord application

To create a bot user account for use with errbot, you can see the required permission settings in the oauth2 page.

Discord provides a tool that can be used to generate a proper invitation link.

The reactiflux community have written a quick start guide to creating a discord bot and getting a token