Sets a player's in-game group based on their Discord role. Works standalone using FiveM's built-in ACE permission system, or hooks directly into ESX, QBCore, or QBox if one of those is detected on the server.
When a player connects (or joins the server, character-loaded, depending on framework), the
resource looks up their linked Discord account, asks the Discord API which roles they have in
your server, and matches those roles against Config.RoleGroups to decide their in-game group.
Online players are also periodically re-checked so role changes on Discord apply without
needing a reconnect.
- Go to the Discord Developer Portal and create a new application.
- Open the Bot tab, add a bot, and copy its token. Keep this secret.
- No privileged intents need to be enabled. This resource only looks up one member at a time by ID, which doesn't require the Server Members intent.
- Under OAuth2 -> URL Generator, tick the
botscope (no bot permissions are required), generate the invite link, and use it to add the bot to your Discord server.
Enable Developer Mode in Discord (User Settings -> Advanced), then:
- Right-click your server icon -> Copy Server ID for
Config.Discord.GuildId. - Right-click each role in Server Settings -> Roles -> Copy Role ID for
Config.RoleGroups.
Edit config.lua:
Config.Discord.BotToken/Config.Discord.GuildId- from steps above.Config.RoleGroups- map each Discord role ID to an in-game group name. Order matters, first match wins, so list your highest ranking roles first.Config.DefaultGroup- what players get if none of the configured roles match.
What a "group" name should be depends on what the resource detects on your server:
- ESX: any group your server recognizes via
xPlayer.setGroup(e.g.admin,superadmin). - QBCore / QBox: a permission level checked with
QBCore.Functions.HasPermission/IsPlayerAceAllowed(e.g.god,admin,mod). - Standalone: any ACE group you've set up yourself in
server.cfg, e.g.add_ace group.admin command allow.
- Copy this folder into your server's
resourcesdirectory. - Add
ensure md_discordtoserver.cfg, after the line that starts your framework (es_extended,qb-core, orqbx_core) if you use one, so auto-detection sees it as already started. - To use the
/discordsyncadmin command, grant it to whichever group should be allowed to force a resync, e.g.:add_ace group.admin command.discordsync allow
On start, the console will print which framework it detected and whether the bot token was verified. If either check fails, it prints the reason and does not start syncing.
/discordsync [server id]- force an immediate resync for a player (defaults to yourself if no ID is given). Restricted to whichever group is granted thecommand.discordsyncACE.
- A player only gets a
discord:identifier if they had the Discord desktop client running while connecting. If it's missing,Config.DefaultGroupis applied instead. - Discord's API rate limits are handled with a short retry using the
retry_aftervalue Discord returns, up to a few attempts.