> For the complete documentation index, see [llms.txt](https://docs.rainmad.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rainmad.com/resources/blackmarkets-player-run-contraband-operation/discord-log.md).

# Discord Log

Blackmarket can post rich, categorized embeds to a Discord webhook. Logging is configured at the top of **`server/discord_log.lua`**.

## Setup

```lua
local config = {
    enabled = false,          -- turn logging on
    webhook = 'WEBHOOK_HERE', -- your Discord webhook URL
    botName = 'Blackmarket',  -- username shown on the embeds
    categories = {            -- toggle whole categories on/off
        admin    = true,
        economy  = true,
        police   = true,
        social   = true,
        security = true,
    },
}
```

1. Create a webhook in **Discord → Channel Settings → Integrations → Webhooks**.
2. Paste its URL into `webhook`.
3. Set `enabled = true`.
4. Restart the resource.

{% hint style="info" %}
You can point each category at a different channel by duplicating the webhook logic, but the simplest setup is one webhook with the categories you care about left `true`.
{% endhint %}

## Categories & events

Each embed is color-coded by category. Turn off a category by setting it to `false`.

| Category     | Color  | Logged events                                                                                                                                                                                         |
| ------------ | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **ADMIN**    | red    | Every admin-panel action (create/delete warehouse, transfer ownership, eject, vault adjust, stock/van wipe, force-respawn van, edit coords/storefront, NPC force start/stop, member add/edit/remove). |
| **ECONOMY**  | blue   | Supply order placed/cancelled, drop picked up, order offloaded, replacement van ordered, van sale opened/closed, customer purchase, NPC vendor purchase, vault deposit/withdraw.                      |
| **POLICE**   | orange | Van searched, van cargo seized, van destroyed.                                                                                                                                                        |
| **SOCIAL**   | green  | Member added, member permissions updated, member removed.                                                                                                                                             |
| **SECURITY** | purple | Anti-abuse signals: customer refund lost on mid-purchase disconnect, vault deposit lost on disconnect, permission-denied attempts.                                                                    |

Every embed includes the warehouse (`#id` + owner) and the actor (name + identifier) when they apply, plus event-specific fields (amounts, item lists, ETAs, coordinates…).

{% hint style="warning" %}
If `enabled = true` but no logs appear, double-check the webhook URL is complete and that the channel still exists. A revoked or wrong URL fails silently.
{% endhint %}
