Skip to content

Events ​

All server events are server-local (AddEventHandler, not RegisterNetEvent). Clients cannot trigger them.

lua
AddEventHandler('np_discord:playerRolesChanged', function(source, roles, added, removed, guildId)
  if exports.np_discord:HasRole(source, 'police') then
    -- give the in-game job, refresh a menu …
  end
end)

Players ​

server

Event Arguments
np_discord:playerReady source, profile First sync after a player joined, once every tracked guild answered
np_discord:playerRolesChanged source, roles, added, removed, guildId Role ids; roles covers every guild, guildId is where it changed. Arrives through the gateway or the Config.Sync poll

Start-up and guilds ​

server

Event Arguments
np_discord:ready guilds Start-up load done: { { id, name, label } } (error instead of label for a guild that failed)
np_discord:guildAdded guildId, name A guild became tracked (found at start, or the bot joined it)
np_discord:guildRemoved guildId, name The bot left a guild, or it is no longer tracked
np_discord:roleUpdated guildId, role | false, roleId A role was created or changed (role) or deleted (false)

Gateway ​

server

These need the gateway and the intent in the last column.

Event Arguments Intent
np_discord:gatewayReady botUser On every (re)connect
np_discord:gatewayClosed reason When the connection drops
np_discord:memberUpdated userId, member, guildId GUILD_MEMBERS
np_discord:memberJoined userId, member, guildId GUILD_MEMBERS
np_discord:memberLeft userId, user, guildId GUILD_MEMBERS
np_discord:memberBanned / np_discord:memberUnbanned userId, user, guildId GUILD_MODERATION
np_discord:voiceStateUpdated userId, state | false, guildId, source | false GUILD_VOICE_STATES
np_discord:message message, source | false GUILD_MESSAGES (+ MESSAGE_CONTENT for the text). DMs to the bot (no guild_id): DIRECT_MESSAGES, always with the text
np_discord:reactionAdded / np_discord:reactionRemoved data GUILD_MESSAGE_REACTIONS
np_discord:interaction interaction, source | false Every interaction, before its handler
np_discord:gateway type, data Every gateway dispatch, raw

source is the online player that belongs to the Discord user, or false.

Client ​

client

Event Arguments
np_discord:profile profile The player's own profile, sent on join and whenever the roles change. See Client

Net events ​

np_discord registers one net event that clients may send: np_discord:requestProfile. It returns the sender's own profile (never somebody else's) and is rate-limited to one request per two seconds. No client event can make the bot do anything. The baseevents death events are only listened to while the built-in death log is on (see Webhooks & logs → Built-in logs).