> For the complete documentation index, see [llms.txt](https://titans-productions.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://titans-productions.gitbook.io/documentation/redm/how-to-add-webhooks.md).

# How to add webhooks

This section applies **only to my own scripts** and does not apply to scripts from other developers.

1. Every script has an option in its **config** that allows you to enable or disable webhooks.
2. Once you enable the webhooks you desire on the specified script, you have to open the following script directory path file `tp_libs/server/webhooks.lua`
3. Inside this file, look for the script for which you enabled webhooks in the config. There, you will add the **Discord webhook URL** that you obtained from the Discord channel where you created the webhook.

**Example:**

```lua
local WEBHOOKS = {

   ["tp_companies"] = {
        ['COMMANDS']  = "webhook_url_here",
   }, 
      
   ["tp_wildlife_missions"] = {
        ['RECEIVED_REWARDS']  = "webhook_url_here",
   }, 
   
   ["tp_stables"] = {
        ['COMMANDS'] = "webhook_url_here",
        ['BOUGHT'] = "webhook_url_here",
        ['SOLD'] = "webhook_url_here",
        ['SOLD_TAMED_HORSE'] = "webhook_url_here",
        ['TRANSFERRED'] = "webhook_url_here",
        ['RECEIVED_TAMED_HORSE'] = "webhook_url_here",
        ['BREEDING'] = "webhook_url_here",
   },
```

Inside the "`webhook_url_here"`, you will place the **webhook URL(s)** that you obtained from the Discord channel where you created the webhook.

You can add a different webhook URL for each available webhook event, depending on where you want the logs to be sent.

### How to create a discord webhook?

It is actually very simple, you have to create a channel (not forum / thread, neither announcements channel) and **right-click** or click the **gear** icon to edit the channel and go to **integrations** section.\ <br>

<figure><img src="https://1388375997-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY2RtqVuE0tQRiqtUiG9D%2Fuploads%2FeNIzjEHTPD1R5rVtenwi%2F%CE%B5%CE%B9%CE%BA%CF%8C%CE%BD%CE%B1.png?alt=media&amp;token=bdbf4b12-5c63-43a1-bbd0-07c1eab9bebf" alt=""><figcaption></figcaption></figure>

\
Once you open the **integrations** section, click on **Create Webhook** button to create your discord server webhook, insert the discord / server name you desired, save and **Copy Webhook Url**\ <br>

<figure><img src="https://1388375997-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY2RtqVuE0tQRiqtUiG9D%2Fuploads%2FkdL5IDHMGqt49aQ9GxRp%2F%CE%B5%CE%B9%CE%BA%CF%8C%CE%BD%CE%B1.png?alt=media&amp;token=06ccd297-3b4c-43b3-ab1c-0cf792ca2dcd" alt=""><figcaption></figcaption></figure>

Once the webhook url is copied, it will return something similar to this `https://discord.com/api/webhooks/xxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -` This is what you need to copy and paste it on the desired webhook on `tp_libs/server/webhooks.lua`
