# Replace your Discord webhooks with FiveDash logs

Your city's script logs arriving in FiveDash, with search and player filters, without rewriting a single script.

Source: https://fivedash.fivex.gg/docs/en/tutorials/webhooks-to-logs

Most scripts send logs to a Discord webhook. Each FiveDash log's link accepts the same message Discord accepts, so you just swap one link for the other in the script's config. In this tutorial you create the logs, swap the links, get the first log and find out who did what. It's for whoever handles the city's scripts.

## What you need

* The **Logs** module in the organization's plan. Each server gets up to 15 logs on Plus, 30 on Pro and 60 on Ultra.
* The **Configure** level on **All logs**: it runs the initial setup and sees the links.
* Access to the server's files, to edit the scripts' config and restart them in the console.

## 1. Pick the logs

Open **Logs** in the sidebar. The first time, **Bring your logs to FiveDash** shows up.

In **Which logs do your scripts send?**, tick the kinds the city uses, like **Deaths and combat**, **Inventory and chests** or **Money and bank**. For a custom log, type its name in **Log name**, under **Other logs** (e.g. "Store robbery"), and click **Add**.

Click **Create the link** (with more than one log, the button shows the number, like **Create 4 links**).

> Create a log for each kind of log your scripts send. A script with several webhooks can point each link to a different log, or all of them to the same log: the **Script** filter and search tell them apart later.

## 2. Swap the links in your scripts

Pick the **Discord webhook** tab and copy each log's link. Then, in each script:

1. Open the script's config (`config.lua`, `shared.lua`…) and look for `discord.com/api/webhooks`.
2. Replace that link with the right log's link. The rest of the script stays the same.
3. In the server console, run `ensure script-name`.

Before and after:

```lua
-- before
Config.Webhook = "https://discord.com/api/webhooks/1234…/aBcD…"

-- after
Config.Webhook = "https://logs.fivex.sh/api/logs/<log-id>/<token>"
```

When you're done, click **I've swapped them**.

> The token at the end of the link is the log's password: anyone with the link can send logs to the server. Copy the link from the dashboard instead of typing it, don't publish it and never put it in client scripts (`client_scripts`).

## 3. Get the first log and turn logs on

Join the city and do something a script records, or click **Send a test log**. When the log arrives, it shows as the script sent it and what FiveDash read from it: character ID, Discord account, identifiers and coordinates.

Click **Turn on logs** (the button only unlocks after the first log has arrived) and then **Go to the logs**.

## 4. Swap the other scripts

Scripts left? Make a log for each and get its link:

* **New log:** in the sidebar, under **Logs**, click **New log**. Give it a name, pick **Discord webhook** under **How the script sends** and click **Create log**. The dialog shows the link to copy.
* **Existing log:** open the log (**Logs →** the log's name), click **How to send** and copy the link. If the log is on the export, click **Use webhook** first.

Swap the link in the script and run `ensure script-name`. To check, do the action in the game or click **Send test** in **How to send**: the log shows up on the log's page right away.

> After the swap, the script only sends to FiveDash: the log stops showing up on Discord. Files the script used to attach (like screenshots) are counted, but not kept.

## 5. Find out who did what

Go to **Logs → All logs**:

1. In the **Search the logs: name, item, plate, command…** box, type what you're looking for.
2. Pick the period. The default is **Last 7 days**.
3. Click **Filters** to filter by **Log**, **Script** (the webhook's `username`) or **Player**. In **Player**, type the ID, Discord or license and press Enter.
4. Click a log to see **Who**, **What happened**, **Where** and **Source**.

The search, filters and period live in the page's address: copy it and send it to someone on the staff, who opens the same search.

## 6. Move to the export (optional)

If you can edit the script, the `fivedash` resource's export is faster, uses no link and already reads the player's character ID. In **How to send**, click **Use export** and then **Copy AI prompt**: paste it into an AI along with the script, and it replaces the `PerformHttpRequest` with the export call.

Or write the call by hand, on the script's server side:

```lua
local function fivedashLog(data)
    if GetResourceState("fivedash") ~= "started" then return end
    exports.fivedash:log("mortes", data)
end

fivedashLog({ title = "Death recorded", player = source })
```

`mortes` is the log's **Key** in the dashboard. The function checks that `fivedash` is running, so the script doesn't break if it's stopped.

> With the `fivedash` resource in the city, logs of the **Joins and leaves**, **Chat and commands** and **Deaths and combat** kinds get joins and leaves, chat and deaths by themselves, with no script at all.

## If nothing arrives

| Check                                              | How                                                                                            |
| -------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| The whole link was pasted                          | Copy it again from **How to send**                                                             |
| The script was restarted                           | Run `ensure script-name` in the console                                                        |
| The link isn't from before a **Generate new link** | An old link gets `401`. Copy the new one and swap it in the script                             |
| Which log is quiet                                 | In **Logs → Overview**, the **Silent** block shows logs that received nothing in the last 24 h |

## Next steps

[Replace Discord webhooks](https://fivedash.fivex.gg/docs/en/logs/migrate-from-webhooks)

What FiveDash accepts and reads from each message.

[Create logs](https://fivedash.fivex.gg/docs/en/logs/create-logs)

Log kinds, keys, links and plan limits.

[Search and filter](https://fivedash.fivex.gg/docs/en/logs/search-and-filter)

Periods, filters and each log's details.

[Exports, events and commands](https://fivedash.fivex.gg/docs/en/developers/exports-and-events)

Every field of the logs export.
