Development ​
Layout ​
fxmanifest.lua node_version '22'; config.lua is a server script, not a shared one
config.lua everything tunable (only Config.Presence reaches clients)
init.lua optional Discord.X(...) shortcut for other resources
lib/json.lua JSON with explicit null and forced objects
lib/util.lua snowflakes, CDN urls, mentions, timestamps, colours, permission bitfields
shared/np_admin.lua np_admin integration lib, vendored byte-identical (loaded server-side only here)
shared/np_admin_settings.lua the settings np_admin shows
server/00_core.lua names → ids for guilds, roles and channels, errors, logging
server/01_http.lua REST client: one queue per rate limit bucket, retries, backoff, uploads
server/02_cache.lua TTL cache with shared in-flight loads
server/03_registry.lua every guild the bot is in: guild object, roles, channels, emojis; discovery
server/10_users.lua … 14_messages.lua users, members / moderation / voice, guild / roles / invites /
events / emojis, channels / threads, messages / webhooks
server/30_players.lua online players, role tracking, profiles, the Config.Sync poll
server/31_connect.lua the whitelist
server/32_logs.lua Log and the built-in logs
server/40_gateway.lua Lua side of the gateway: caches, events, bot activity
server/41_commands.lua slash commands, components, modals, autocomplete
server/50_features.lua chat bridge, status message, bot activity, job roles
server/99_exports.lua every Discord.* function becomes an export; start-up check
server/gateway.js the WebSocket (Node 22): identify, heartbeat, resume, reconnect
client/main.lua the player's own profile, client exports, rich presence
docs/API.md the export reference these pages follow
tests/ plain Lua 5.4 + Node 22, no FiveM needed
Every function in the server's Discord table becomes an export. Inside the resource a failure is nil, err; on the
way out it becomes false, err, because a return list that starts with nil can arrive empty in another resource and
lose the error.
Tests ​
sh
tests/run.sh # everything
VERBOSE=1 tests/run.sh # with the resource's log lines
Plain Lua 5.4 and Node 22, no FiveM needed. LUA and LUAC pick other binaries.
| Step | |
|---|---|
| syntax | luac -p on every Lua file |
| server | tests/test_server.lua: the server files against a fake Discord: rate limits, retries, caching, roles, whitelist, logs, chat bridge, slash commands |
| multi-guild | tests/test_multiguild.lua: a main server, a faction server and a staff server at once |
| registry | tests/test_registry.lua: discovery, the guild registry, live updates and background refreshes |
| np_admin | tests/test_np_admin.lua: the vendored lib and the settings against a fake np_admin |
| docs | tests/test_docs.lua: docs/API.md lists every export with the argument names the code uses, and nothing else |
| gateway | node --test tests/gateway.test.js: the gateway client against a fake socket |
tests/harness.lua stubs the FiveM natives the server files use, runs a cooperative scheduler with a virtual clock and
puts a fake Discord behind PerformHttpRequest. It boots the server files in manifest order.
Keeping these pages in sync ​
The Exports page follows docs/API.md in the resource, which tests/test_docs.lua checks against the code.
Update both together.