Installation ​
Requirements ​
- A FiveM server artifact with Lua 5.4
- A Discord application with a bot user that is on your Discord server
- For the gateway (slash commands, live role updates, Discord → game chat, the bot's activity line): a
server artifact with the Node 22 runtime. The manifest sets
node_version '22'.
Nothing else. No framework, no database. Optional, detected by their events:
| Resource | Used for |
|---|---|
| es_extended, qb-core, qbx_core | Job roles (Config.JobRoles) |
| chat | The chat bridge and the built-in chat log |
| baseevents | The built-in death log |
| np_admin | Editing settings live (see Configuration → Editable in np_admin) |
1. Create the bot ​
- Open the Discord developer portal → New Application → Bot →
Reset Token. Copy the token; it goes into
server.cfgin step 3. - Under Privileged Gateway Intents switch on:
- Server Members Intent: member lists (
ListMembers,GetAllMembers,GetMembersWithRole) and live role updates through the gateway. - Message Content Intent: only for the Discord → game side of the chat bridge.
- Presence Intent: only if you add
GUILD_PRESENCEStoConfig.Gateway.intents.
- Server Members Intent: member lists (
The gateway stops with a clear console message (disallowed intents …) when Config.Gateway.intents lists a
privileged intent that is not switched on here.
2. Invite it ​
Invite the bot to every guild you use (main guild, Config.Guilds, any guild you want discovered) with the scopes
bot and applications.commands. Give it the permissions for what you want to do:
| Permission | Needed for |
|---|---|
| Manage Roles | AddRole, RemoveRole, SetRoles, job roles, role management, np_admin's two-way sync |
| Manage Nicknames | SetNickname |
| Kick Members / Ban Members / Moderate Members | Kick, Ban, Unban, BulkBan, Timeout |
| Move Members (plus Mute / Deafen Members) | MoveMember, DisconnectMember, MuteMember, DeafenMember |
| Manage Channels | Creating and editing channels and permission overwrites |
| Manage Webhooks | CreateWebhook and the other webhook management exports |
| Send Messages (and Embed Links) | Messages, logs to bot channels, the status message, the chat bridge |
| View Audit Log | GetAuditLog |
Role order
Drag the bot's role above every role it should hand out. Discord refuses anything else with
50013 Missing Permissions, even when the bot has Manage Roles.
Give the bot only the permissions you actually use. Every resource on your server can call np_discord's exports (see Security).
3. server.cfg ​
Copy the folder into your resources as np_discord (other resources call exports.np_discord, so keep the name)
and add:
set discord_bot_token "YOUR-BOT-TOKEN" # `set`, never `setr`: setr would send it to every client
set discord_guild_id "123456789012345678" # the main guild
set discord_webhook_joins "https://discord.com/api/webhooks/…" # optional, one per log channel
ensure np_discord # before the resources that use it
| Convar | |
|---|---|
discord_bot_token |
The bot token. A leading Bot is stripped. Read on the server only |
discord_guild_id |
The main guild. It is always called main |
discord_webhook_<name> |
Webhook url for the log channel <name> (see Webhooks & logs). Only Discord's hosts are accepted |
np_discord also reads sv_projectName (falling back to sv_hostname) for {server} and sv_maxclients for {max}
in the status message, the bot's activity and rich presence.
Start np_discord before np_admin and the other resources that use it, so their start-up checks find it.
4. Configure ​
Name the roles and channels you use all the time in config.lua (Config.Roles, Config.Channels) and switch on what
you need: whitelist, logs, chat bridge, status, gateway, job roles, rich presence. Naming is optional: roles and
channels can be passed by their name on Discord. See Configuration.
To use the Discord.X(...) shortcut in your own resources, add this to their fxmanifest.lua:
server_script '@np_discord/init.lua' -- or shared_script: it works on the client too
Then Discord.HasRole(source, 'police') is the same as exports.np_discord:HasRole(source, 'police').
Check it works ​
On start the server console shows one line per tracked guild:
[np_discord] ready as MyBot in "My Server" (main, 1234 members, 42 roles)
or what is missing:
| Console line | Fix |
|---|---|
convar discord_bot_token is not set |
Add set discord_bot_token "…" to server.cfg |
convar discord_guild_id is not set |
Add set discord_guild_id "…" |
could not log in to Discord: … |
The token is wrong or was reset |
bot … cannot see guild … |
The bot is not on that guild: invite it |
gateway stopped: disallowed intents … |
Switch the privileged intents on in the developer portal, or remove them from Config.Gateway.intents |
gateway stopped: this server artifact has no built-in WebSocket … |
Use an artifact with the Node 22 runtime, or set Config.Gateway.enabled = false |
Config.Connect.roles: cannot resolve role … |
A whitelist role does not exist. Every connection is refused until it is fixed |
log channel "x" has no destination |
Set discord_webhook_x or add x to Config.Logs.channels |
Config.Debug = true logs every request and gateway event.