Discord Setup Guide
This guide walks you through creating a Discord bot from scratch, configuring its permissions, and connecting it to Elftia so that your AI Agent works inside your Discord server.
Prerequisites
- A Discord account
- A Discord server where you have admin permissions (or create a new test server)
- Elftia installed with at least one LLM provider configured
Step 1: Create a Discord Application
- Open the Discord Developer Portal
- Click New Application in the upper right
- Enter an application name (e.g.,
Elftia Bot) and click Create - Click Bot in the left-hand menu
- Note the bot username shown on the page
Step 2: Obtain a Bot Token
- On the Bot page, find the Token section
- Click Reset Token (if this is your first time, the token will be shown directly)
- Copy the token and store it securely
:::danger Security Warning A Bot Token is equivalent to the bot's password. Never share it publicly or commit it to a repository. If the token is leaked, reset it immediately in the Developer Portal. :::
Step 3: Configure Bot Permissions
On the Bot page, find the Privileged Gateway Intents section and enable the following two options:
- MESSAGE CONTENT INTENT — allows the bot to read message content (must be enabled)
- SERVER MEMBERS INTENT — allows retrieving server member information (recommended)
Click Save Changes at the bottom of the page.
:::info Why Is the Message Content Intent Needed? Since 2022, Discord requires all bots to explicitly enable the Message Content Intent in order to read message content. Without it, the bot receives only empty messages. :::
Step 4: Generate an Invite Link
- Click OAuth2 → URL Generator in the left-hand menu
- Check
botunder SCOPES - Check the following permissions under BOT PERMISSIONS:
| Permission | Description |
|---|---|
| Send Messages | Send messages |
| Read Message History | Read message history |
| View Channels | View channels |
| Embed Links | Send embedded links |
| Attach Files | Send file attachments |
| Add Reactions | Add emoji reactions |
| Use External Emojis | Use external emojis |
- Copy the GENERATED URL at the bottom of the page
Step 5: Invite the Bot to Your Server
- Open the invite link copied in the previous step in a browser
- Select the target server (you must have Manage Server permission on that server)
- Review the permissions list
- Click Authorize and complete the CAPTCHA
After a successful invite, you will see the bot in the server's member list (shown as offline, since it hasn't connected yet).
Step 6: Configure in Elftia
- Open Elftia and go to Settings → Channel
- Click Add Channel
- Select Discord (if the plugin is not installed, it will be downloaded from the Marketplace automatically)
- Fill in the configuration form:
| Field | Value |
|---|---|
| Display name | A name for this instance (e.g., My Discord Bot) |
| Bot Token | Paste the token obtained in Step 2 |
- Click Test Connection to verify the token is valid
- Click Save to create the Channel instance
Step 7: Configure Trigger Rules
After creating the instance, it is recommended to configure appropriate trigger rules:
| Mode | Recommended For | Configuration |
|---|---|---|
mention | Multi-user servers | Agent replies only when @mentioned. Set mentionName to the bot's username |
all | Dedicated/test servers | Agent replies to all messages; suitable for personal use |
keyword | Topic-specific channels | Set a list of trigger keywords; case-insensitive |
dm_only | Public servers | Agent replies to direct messages only; completely silent in groups |
Select the trigger mode and configure the corresponding parameters in the Channel settings.
Step 8: Start the Connection
- Find the Discord instance you just created on the Channel page
- Click the Connect button (or enable Auto Connect)
- Wait for the status to change to Connected (green indicator)
- Send a message to the bot in Discord to test it
If using mention mode, remember to @mention the bot in your message:
@Elftia Bot Hello, please introduce yourself
Discord Platform Features
| Feature | Support |
|---|---|
| Group chat | Supported |
| Direct messages (DM) | Supported |
| Attachments/file sending | Supported |
| Typing indicator | Supported |
| Emoji reactions | Supported |
| Threads/forums | Partially supported |
| Message length limit | 2,000 characters |
When the Agent's reply exceeds 2,000 characters, the system automatically splits it into multiple messages. Splitting is done preferentially at newlines, then at spaces, and finally as a hard cut.
FAQ
Bot Shows as Offline
- Check whether the Channel instance status in Elftia shows "Connected"
- Confirm the Bot Token is correct
- Confirm the Elftia app is running (Channel plugins run in the main process; the bot goes offline when the app is closed)
Bot Is Online but Not Responding
- Check that the trigger rule configuration is correct. If using
mentionmode, ensurementionNamematches the bot's actual username - Confirm that MESSAGE CONTENT INTENT is enabled in the Developer Portal
- Check the Elftia logs for any records of security pipeline interceptions (RateLimiter, PromptGuardian, etc.)
- Confirm the Agent has an LLM provider and model properly configured
Messages Are Truncated
Discord's single-message limit is 2,000 characters. If the Agent's reply is too long, the system splits it and sends multiple messages. If a reply appears incomplete, check for follow-up messages.
Permission Errors (Missing Permissions)
- Confirm the bot has Send Messages and View Channel permissions in the target channel
- Check whether any override rules in the server role settings restrict the bot's permissions
- Regenerate the invite link in the Developer Portal and confirm all required permissions are checked
Multiple Discord Instances
You can create multiple Discord Channel instances in Elftia, each using a different Bot Token and connecting to a different server. Each instance can have independent trigger rules and security policies.
Next Steps
- Trigger Rules & Security — learn more about trigger mode and security pipeline configuration
- Multi-Platform Channels Overview — explore other supported platforms