Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

md_discord

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.

How it works

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.

Setup

1. Create a Discord bot

  1. Go to the Discord Developer Portal and create a new application.
  2. Open the Bot tab, add a bot, and copy its token. Keep this secret.
  3. 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.
  4. Under OAuth2 -> URL Generator, tick the bot scope (no bot permissions are required), generate the invite link, and use it to add the bot to your Discord server.

2. Get your IDs

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.

3. Configure

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.

4. Install

  1. Copy this folder into your server's resources directory.
  2. Add ensure md_discord to server.cfg, after the line that starts your framework (es_extended, qb-core, or qbx_core) if you use one, so auto-detection sees it as already started.
  3. To use the /discordsync admin 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.

Commands

  • /discordsync [server id] - force an immediate resync for a player (defaults to yourself if no ID is given). Restricted to whichever group is granted the command.discordsync ACE.

Notes

  • A player only gets a discord: identifier if they had the Discord desktop client running while connecting. If it's missing, Config.DefaultGroup is applied instead.
  • Discord's API rate limits are handled with a short retry using the retry_after value Discord returns, up to a few attempts.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages