Run your own Discord bot for your game: in-game chat in a Discord channel, roles for linked players, and slash commands like /online and /leaderboard.
Discord Bot
Your game can run your own Discord bot, with your game's name and avatar, on your Discord server. It does three things:
- Chat bridge. In-game global chat appears in a Discord channel, and that channel's messages appear in game as [Discord] name.
- Roles for linked players. Players link their game account to Discord. The bot then gives them roles you choose: for linking, by level, for premium, or by in-game guild.
- Slash commands.
/online,/who,/leaderboardand/statuson your server, answered live by your game server./linkis always there.
To post game news (server online, boss slain, events) to Discord, see Discord Announcements. That needs only a webhook, no bot.
Where to author it#
Settings → Discord bot in the studio, below Discord announcements.
Setting it up#
- Open the Discord Developer Portal and click New Application. Name it after your game; that's the bot's name.
- Open Bot. Click Reset Token and copy the token. Treat it like a password.
- For the chat bridge's Discord → game half, turn on Message Content Intent on the same page and save.
- In Discord, open User Settings → Advanced and turn on Developer Mode, so you can copy IDs.
- In the studio, open Settings → Discord bot. Paste the Bot token and your Discord server ID (right-click your server's icon → Copy Server ID).
- Fill in the parts you want (below), switch the bot on and click Save.
- Click Test. It checks the token and the IDs and shows a link: Add the bot to your server. Open it, pick your server and authorize. The link already asks for the permissions the bot needs.
- In Discord, open Server Settings → Roles and drag the bot's role above every role it should hand out.
- Publish (or restart your server) if your world runs on a managed server, so it picks up the settings.
The fields#
| Field | What it does |
|---|---|
| On / off | Off = the bot never connects. Your settings stay saved. |
| Bot token | From Bot → Reset Token. After saving, the editor shows only its last 4 characters. Leave it blank when saving to keep the stored one; Forget token removes it and switches the bot off. |
| Discord server ID | The server the bot works in. Slash commands and roles only work there. |
| Chat bridge | On = in-game global chat goes to the channel below. |
| Discord channel ID | The channel mirrored with global chat (right-click the channel → Copy Channel ID). |
| Discord → game too | The channel's messages show up in game as [Discord] name. Needs Message Content Intent. Off = game → Discord only. |
| Slash commands | On = /online, /who, /leaderboard and /status on your server. /link is there either way. |
| Linked players get | A role ID for everyone who links their game account. |
| Premium members get | A role ID for players whose premium membership is active. |
| By level | "Level 20 and up → this role". Add up to 10 bands. A player gets only the highest band they've reached. |
| By in-game guild | Pick one of your world's guilds and a role for its members. Up to 20. |
How players link their account#
- In game, they type
/discordin chat. The game answers with a six-letter code, good for 10 minutes. - In your Discord server, they type
/linkfollowed by the code. - The bot answers (only they see it) and gives them their roles.
Players who sign in with Discord are linked already. /discord unlink in game removes the link and the roles this bot gave.
When roles update#
- right after linking;
- when the player logs in (at most every 10 minutes);
- when they level up.
The bot only ever adds or removes the roles in your rules (and ones it gave before you removed a rule). Roles your moderators hand out are never touched.
Slash commands#
| Command | Answers |
|---|---|
/online | How many are playing, with up to 25 names and levels. |
/who name | A character's level, and whether they're online or when they were last seen. |
/leaderboard | The 10 highest-level characters. |
/status | Whether the game is up, how many are playing, and for how long it's been running. |
/link code | Links the player's game account (see above). |
Gotchas#
- "Turn on Message Content Intent" in the editor or on your server's status page means the Discord → game half can't start. Turn the intent on (Bot page) or switch Discord → game too off.
- "Discord refused the bot token": the token was reset or mistyped. Reset it again and paste the new one.
- "The bot is missing a permission" when roles should change: its role must be above the roles it gives, and it needs Manage Roles. Use the invite link from Test to add it with the right permissions.
- Commands don't appear? They're registered on your server when the bot connects. Give Discord a minute, or restart Discord.
- Only global chat is bridged. Party, guild, zone and whisper chat never leave the game, and neither do slash commands typed in chat.
- Muted players aren't bridged, and nothing from Discord can ping anyone in game or in Discord: mentions show as "@someone".
- Bursts are capped. Discord → game allows about 8 messages every 10 seconds in total, and one every 2 seconds per person.
- Your server must be running and online for the bridge, commands and roles. A desktop playtest only runs the bot while it's open.
- Big games on several shards: one shard runs the Discord connection.
/onlineand/statuscount the players on that shard. - The token is a password. It's stored with your world, sent only to Discord, removed from offline desktop exports and left out of project archives. If it ever leaks, reset it in the Developer Portal.
- The whole system sits behind the Discord Bot feature flag. Off = the bot never connects.