Server-side ESX helper that syncs a player's ESX group from their Discord roles.
- Map Discord role IDs to ESX groups (admin, senior, staff, trial, …).
- Priority-based resolution if a player has multiple roles.
- Auto-update on player load and manual full reload via console command.
- ESX Legacy (
es_extended). - Discord bot in your guild with a valid token.
- Bot must have the Server Members (Guild Members) intent enabled in the Developer Portal.
- Players must have a Discord identifier.
- Place this resource into your server resources.
- In
server.cfg, start it after ESX and set the bot token convar:ensure es_extended ensure sd_playergroups set discordBotToken "YOUR_BOT_TOKEN_HERE"
- Configure
config.lua. - Done.
- On
esx:playerLoaded, the script:- Reads the player's
discord:identifier. - Calls Discord API to get member's roles.
- Picks the highest-priority group from the member's roles.
- Sets player's group to that value, or
userif none match.
- Reads the player's
- Console only:
/reloadplayergroups(or the name you set inConfig.ReloadCommand):- Reloads all online players' groups.
Config.Tokenis read from thediscordBotTokenconvar; keep tokens out of source control.- Ensure your bot is in the guild, token is valid, and the Server Members intent is enabled. Discord API must return HTTP 200.
- Author:
fashion.demon