Discord DMs ​
Players can ask your server's Discord bot for their saved codes. They DM the bot passwords and get their whole
keychain, or password bank and get the entries that match. It works while they are offline, so a player who forgot
the safe code can look it up from their phone. It needs np_discord and is off by default,
because the codes leave the game server.
Setup ​
- Run np_discord with the gateway on (
Config.Gateway.enabled = true). - For text DMs, add
DIRECT_MESSAGESto np_discord'sConfig.Gateway.intents. It is not privileged, so there's nothing to switch on in the developer portal. The slash command works without it. - Turn it on in np_passwords:luaor under Resource settings → Passwords → Discord in np_admin (takes effect after a restart).
Config.Discord = { enabled = true, ... } - Players link Discord in FiveM (Settings → Connections) and join the server once with each character.
If DIRECT_MESSAGES is missing, np_passwords prints a warning at start.
Which characters an account sees ​
When a character loads, np_passwords stores it against the Discord account from the player's discord: identifier
(table np_pw_discord). A Discord account reads every character that last loaded with it, one embed per character.
- A character that loads with a different Discord account moves to that account. The old one loses it.
- A character that loads without Discord is unlinked.
- Characters that never loaded while
Config.Discord.enabledwas on are not linked yet.
Only the personal keychain is sent. Shared vault items are not, because their ranks can only be checked while the player is online. Recently deleted entries stay out.
Text DMs ​
| The player sends | The bot answers with |
|---|---|
passwords (or list, all, passwörter, alle) |
Every entry |
password <search> (or pw, find, passwort, suche) |
Entries whose label, username, lock id or lock name contains the search (any case) |
| Any other text | The same search, for example just fleeca |
help (or ?, hilfe) |
A short explanation |
A leading / or ! is ignored. The words are in Config.Discord.words.
Each line is **Label** · username · ||code||. The code is a spoiler, so it stays hidden until the player clicks it.
Labels, usernames and codes are escaped and can't format the message or mention anyone. An entry without a code (access
granted without knowing it) says access only, no code saved; a code older than the lock's current one is marked
outdated.
The bot deletes its answer after Config.Discord.deleteAfter seconds (120). The footer tells the player when.
Slash command ​
/passwords [search] (Config.Discord.command) is registered as a global command that only shows up in DMs with the
bot. The search option autocompletes the player's entry labels. Only labels are sent for that, never codes. The answer
is ephemeral. Set command = false to use text DMs only.
Safety ​
- Only the linked Discord account gets an answer. Messages in servers, from bots and from webhooks are ignored.
Config.Discord.rolelimits it to accounts holding an np_discord role ('whitelisted','lspd/Officer', an id).- At most
perMinutelookups (6) per account and minute;helpis not counted. - When a character's codes were sent, the character gets an in-game alert if it is online (
notify). - Each lookup goes to the np_admin audit log as
discord_lookupwith the Discord id and the number of entries. Codes are never logged.
Configuration ​
Config.Integrations.discord = 'auto' -- 'auto' | true | false
Config.Discord = {
enabled = false,
command = 'passwords',
role = nil,
deleteAfter = 120,
perMinute = 6,
maxEntries = 100,
notify = true,
words = {
list = { 'passwords', 'list', 'all', 'passwörter', 'alle' },
find = { 'password', 'pw', 'find', 'passwort', 'suche' },
help = { 'help', '?', 'hilfe' },
},
}
| Option | Description |
|---|---|
enabled |
Turn the feature on. Links are written only while it is on |
command |
Name of the DM-only slash command; false = text DMs only |
role |
np_discord role an account must hold; nil = every linked account |
deleteAfter |
Seconds until the bot deletes a text-DM answer; 0 keeps it |
perMinute |
Lookups per Discord account and minute |
maxEntries |
Entries per answer. Long keychains are split over several embeds and messages |
notify |
In-game alert to the character when its codes were sent |
words |
First words of a text DM, any case |
The bot's texts follow Config.Locale (en, de).