> For the complete documentation index, see [llms.txt](https://wxn-studios.gitbook.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wxn-studios.gitbook.io/documentation/fivecraft-scripts/weapon-repairs/installation/webhooks.md).

# Webhooks

I believe keeping track of what happens on your server is crucial for maintaining a balanced economy and spotting potential issues. That's why I've included a built-in logging system that sends detailed reports directly to your Discord.

{% hint style="info" %}
The webhook configuration is kept server-side for security reasons. You can find it in `server/sv_webhooks.lua`.
{% endhint %}

## Configuration

```lua
Config.Webhooks = {
    enabled = true,
    url = 'https://discord.com/api/webhooks/YOUR_WEBHOOK_URL',
    color = 3066993, -- The color of the embed (Green by default)
    title = 'Weapon Repaired'
}
```

### Setting it up

{% stepper %}
{% step %}

### Create a Webhook

* Go to your Discord server settings -> Integrations -> Webhooks.
* Create a new webhook and copy the URL.
  {% endstep %}

{% step %}

### Paste the URL

* Replace `YOUR_WEBHOOK_URL` in `server/sv_webhooks.lua` with the one you just copied.
  {% endstep %}

{% step %}

### Enable Logs

* Ensure `enabled` is set to `true`.
  {% endstep %}
  {% endstepper %}

## What gets logged?

Every time a player successfully repairs a weapon, a log is sent containing:

* **Player Name**: The name of the player performing the repair.
* **Identifier**: The player's license (useful for bans/tracking).
* **Weapon**: The name/label of the weapon being repaired.
* **Cost**: The materials consumed during the repair.
* **Location**: The coordinates where the repair took place.

## Customization

If you want to change the format or add more fields, you can edit the `SendWebhook` function in `server/sv_webhooks.lua`.

```lua
local embed = {
    {
        ["color"] = Config.Webhooks.color,
        ["title"] = "**"..title.."**",
        ["description"] = message,
        ["footer"] = {
            ["text"] = "FiveCraft Weapon Repairs • " .. os.date("%Y-%m-%d %H:%M:%S"),
        },
    }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://wxn-studios.gitbook.io/documentation/fivecraft-scripts/weapon-repairs/installation/webhooks.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
