JJM Modifications
🛡️

Discord Logging

How to set up and customise Discord webhook logging for JM-NPCRoadRage.

JM-NPCRoadRage can post formatted embeds to a Discord channel every time a road rage incident, police dispatch, player injury, or admin action occurs.

Creating a Webhook#

  1. Open Discord and navigate to the channel where you want logs to appear.
  2. Open Channel Settings → Integrations → Webhooks.
  3. Click New Webhook, give it a name (e.g. Road Rage Bot), and click Copy Webhook URL.

Configuring the Webhook#

Paste the URL into config.lua:

Config.Discord = {    enabled    = true,    webhook    = "https://discord.com/api/webhooks/YOUR_ID/YOUR_TOKEN",    botName    = "Road Rage Bot",    serverName = "My Server",  -- appears in embed footers}
Warning

Keep your webhook URL private. Anyone with the URL can post messages to your channel.

Logged Event Types#

EventEmbed colourWhen it fires
Road rage incidentOrangeAn NPC attacks a player.
Police notificationBluePolice are dispatched to an incident.
Player injuryRedA player receives an injury from an NPC.
Admin actionPurpleAn admin uses a command such as /npcrage-stats.
System statisticsGreenHourly summary (disabled by default).

Turn individual event types on or off:

Config.Discord.logEvents = {    roadRageIncidents   = true,    policeNotifications = true,    playerInjuries      = true,    adminActions        = true,    systemStats         = false,  -- high volume; leave off unless needed}

Spam Prevention#

The resource includes built-in rate limiting to avoid flooding your channel.

OptionDefaultDescription
spamPrevention.enabledtrueEnables all spam prevention.
spamPrevention.cooldownTime60000Milliseconds between similar log types (60 s).
spamPrevention.maxLogsPerMinute5Maximum logs per type per minute.
spamPrevention.combineIncidentstrueBatches excess road rage incidents into a single combined embed.

Quiet Hours#

You can reduce logging during low-activity hours to keep your channel clean:

Config.Discord.spamPrevention.quietHours = {    enabled      = true,    startHour    = 2,   -- 2 AM server time    endHour      = 8,   -- 8 AM server time    reducedTypes = { "roadRageIncidents", "policeNotifications" },}

Role Mentions#

To ping a Discord role when specific events fire, add role IDs:

Config.Discord.mentionRoles = {    adminRole  = "YOUR_ADMIN_ROLE_ID",   -- pinged on admin actions    policeRole = "YOUR_POLICE_ROLE_ID",  -- pinged on police notifications}

Leave a value as "" to disable pinging for that event type.

Tip

To find a role ID in Discord, enable Developer Mode under User Settings → Advanced, then right-click the role and select Copy ID.