Discord Setup
Setup instructions for the Discord bot. See Discord Integration for feature overview.
1. Create a Discord Application
- Go to the Discord Developer Portal
- Click New Application and give it a name
- Go to the Bot tab
- Click Reset Token and copy the token
Keep Token Secret
Never share your bot token publicly. Treat it like a password.
2. Configure Bot Permissions
Your bot needs these permissions:
| Permission | Required For |
|---|---|
| Send Messages | Chat relay (game → Discord) |
| Read Message History | Chat relay context |
| Change Nickname | Displaying farm name as bot nickname |
3. Invite the Bot to Your Server
- Go to OAuth2 → URL Generator
- Select scopes:
bot - Select permissions:
Send Messages,Read Message History,Change Nickname - Copy the generated URL and open it in your browser
- Select your Discord server and authorize
4. Set Environment Variables
Add to your .env file:
DISCORD_BOT_TOKEN=your_bot_token_hereIf you have API_KEY set for API authentication, add it here too so the bot can access the server API:
DISCORD_BOT_TOKEN=your_bot_token_here
API_KEY=your_api_key_hereThis is enough for server status display (player count and invite code in bot presence).
Chat Relay Setup
To enable two-way chat between Discord and the game, additional setup is required.
1. Create a Text Channel
Create a dedicated text channel in your Discord server for the chat relay:
- Right-click your server → Create Channel
- Select Text as the channel type
- Name it something like
#stardew-chat - (Optional) Set channel permissions so only certain roles can send messages
Dedicated Channel Recommended
Use a dedicated channel for chat relay. All messages in this channel will be sent to the game, and all game chat will appear here.
2. Enable Message Content Intent
- Go to Discord Developer Portal
- Select your application → Bot
- Under Privileged Gateway Intents, enable Message Content Intent
- Save changes
Why This Is Needed
Discord requires explicit permission to read message content. Without this, the bot can't relay messages from Discord to the game.
3. Get Channel ID
- In Discord, go to User Settings → Advanced
- Enable Developer Mode
- Right-click the chat relay channel → Copy ID
4. Configure Environment
Add the channel ID to your .env:
DISCORD_BOT_TOKEN=your_bot_token
DISCORD_CHAT_CHANNEL_ID=123456789012345678If you have API authentication enabled:
DISCORD_BOT_TOKEN=your_bot_token
DISCORD_CHAT_CHANNEL_ID=123456789012345678
API_KEY=your_api_keyHow Chat Relay Works
Once configured:
| Direction | Format |
|---|---|
| Game → Discord | **PlayerName**: message |
| Discord → Game | (Web) DiscordName: message |
Bot Nickname
The bot's nickname in Discord servers can be configured:
| Configuration | Behavior |
|---|---|
| Not set | Uses farm name from game |
DISCORD_BOT_NICKNAME=value | Uses fixed custom name |
Example:
DISCORD_BOT_NICKNAME=Stardew Valley ServerExample Configuration
Complete Discord setup in .env:
# Discord Bot
DISCORD_BOT_TOKEN=MTIzNDU2Nzg5MDEyMzQ1Njc4OQ.XXXXXX.XXXXXXXXXXXXXXXXXXXXXXXXXXX
DISCORD_CHAT_CHANNEL_ID=123456789012345678
DISCORD_BOT_NICKNAME=Junimo Farm
# API authentication (required if API_KEY is set on server)
API_KEY=your_api_key_hereSecurity Considerations
Rate Limiting
The chat relay does not currently implement rate limiting. Discord users could potentially spam the game chat. Consider using Discord's built-in slowmode on the relay channel if this is a concern.
Slowmode Setup
- Right-click the relay channel in Discord
- Click Edit Channel
- Under Slowmode, set a delay (e.g., 5 seconds)
Troubleshooting
Bot Not Coming Online
- Verify
DISCORD_BOT_TOKENis correct - Check server logs:
docker compose logs -f - Ensure the bot was invited with correct permissions
Messages Not Relaying
- Verify Message Content Intent is enabled
- Check
DISCORD_CHAT_CHANNEL_IDis correct - Ensure bot has permission to read/send in that channel
Wrong Bot Nickname
- Check
DISCORD_BOT_NICKNAMEin.env - Restart the server:
docker compose restart - Bot may need "Change Nickname" permission in Discord server
Bot Shows "Server Offline" But Server Is Running
- If
API_KEYis set on the server, ensure the same key is set for the Discord bot - Check the bot logs for authentication errors:
docker compose logs discord-bot - Verify the bot can reach the server API (network/firewall issues)