> For the complete documentation index, see [llms.txt](https://docs.luarmor.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.luarmor.net/webhook-protection/useful-sample-scripts.md).

# Useful Sample Scripts

## Game Joiner:

{% code overflow="wrap" lineNumbers="true" fullWidth="true" %}

````lua
local function sendJoinScript()
    LRM_SEND_WEBHOOK(
        "https://discord.com/api/webhooks/4382635989158629991/9LtiYbxWZUCfeKKlMhmO2K5k5CSvsBxPck8iFCeMNyY8XkBeaY_8-SHWWJosYFRqV00Q",
        {
            username = "Cat Joiner",
            embeds = {
                {
                    title = "Join Script",
                    description = "Sent by discord user: <@%DISCORD_ID%>",
                    color = 0x00FF00,
                    fields = {
                        {
                            name = "Job ID:",
                            value = "```" .. LRM_SANITIZE(game.JobId, "[a-fA-F0-9\\-]{36}") .. "```",
                            inline = false
                        },
                        {
                            name = "Join script:",
                            value = "```lua\ngame:GetService('TeleportService'):TeleportToPlaceInstance(" ..
                                LRM_SANITIZE(game.PlaceId, "[0-9]{4,22}") ..
                                    ", '" ..
                                        LRM_SANITIZE(game.JobId, "[a-fA-F0-9\\-]{36}") ..
                                            "', game:GetService('Players').LocalPlayer)```",
                            inline = false
                        }
                    }
                }
            }
        }
    )
end
````

{% endcode %}

<div data-full-width="true"><figure><img src="/files/2MuJ2mbToeY8SC98By7a" alt=""><figcaption><p>Game joiner webhook notification</p></figcaption></figure></div>

## Detailed Execution Logs:

{% code overflow="wrap" lineNumbers="true" fullWidth="true" %}

```lua
local function sendDetailedExecutionLog()
    LRM_SEND_WEBHOOK(
        "https://discord.com/api/webhooks/4382635989158629991/9LtiYbxWZUCfeKKlMhmO2K5k5CSvsBxPck8iFCeMNyY8XkBeaY_8-SHWWJosYFRqV00Q",
        {
            username = "Catkeeper",
            embeds = {
                {
                    title = "User executed!",
                    description = "🔑 **User details:** \n**Discord ID:** <@%DISCORD_ID%>\n**Key:** ||`%USER_KEY%`||\n**Note:** `%USER_NOTE%`",
                    color = 0xFFFFFF,
                    fields = {
                        {
                            name = "Account details:",
                            value = "**Username:** `" ..
                                LRM_SANITIZE(game:GetService("Players").LocalPlayer.Name, "[a-zA-Z0-9_]{2,60}") ..
                                    "`\n**User ID:** `" ..
                                        LRM_SANITIZE(game:GetService("Players").LocalPlayer.UserId, "[0-9]{2,35}") ..
                                            "`",
                            inline = false
                        },
                        {
                            name = "IP:",
                            value = "%CLIENT_IP% :flag_%COUNTRY_CODE%:",
                            inline = true
                        }
                    }
                }
            }
        }
    )
end
```

{% endcode %}

<div data-full-width="true"><figure><img src="/files/qxx0dzxtUoNfg5luQ2xo" alt=""><figcaption><p>Detailed execution log notification. You should inform your users if you are logging such information.</p></figcaption></figure></div>

## Unique Item Alert:

{% code overflow="wrap" lineNumbers="true" fullWidth="true" %}

```lua
local function sendUniqueItemAlert(catType, catAmount)
    LRM_SEND_WEBHOOK(
        "https://discord.com/api/webhooks/4382635989158629991/9LtiYbxWZUCfeKKlMhmO2K5k5CSvsBxPck8iFCeMNyY8XkBeaY_8-SHWWJosYFRqV00Q",
        {
            username = "Cat Detected",
            embeds = {
                {
                    title = "Rare cat found!",
                    description = "💎 Found by: <@%DISCORD_ID%>",
                    color = 0xFF00FF,
                    thumbnail = {
                        url = "https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Ftr.rbxcdn.com%2F30DAY-DynamicHeadCostume-BC61C024C184A6545E79DC2737B83AB8-Png%2F420%2F420%2FDynamicHeadCostume%2FPng%2FnoFilter&f=1&nofb=1&ipt=2d150e25fd93aade56a30c3b6eda21a373bd8a7053a606b2dc39b283d23d62f6"
                    },
                    fields = {
                        {
                            name = "Cat details:",
                            value = "**Type:** " .. LRM_SANITIZE(catType, "(Super Rare|Rare|Common) Cat"),
                            inline = true
                        },
                        {
                            name = "Quantity:",
                            value = LRM_SANITIZE(catAmount, "[0-9]{1,7}") .. "x",
                            inline = true
                        }
                    }
                }
            }
        }
    )
end
```

{% endcode %}

<div data-full-width="true"><figure><img src="/files/8GwYAuMImkpvuHbytlQu" alt=""><figcaption></figcaption></figure></div>

## Script Error Logger:

{% code overflow="wrap" lineNumbers="true" fullWidth="true" %}

````lua
local function errorLogger(errorMsg)
    -- relay script errors to webhook
    LRM_SEND_WEBHOOK(
        "https://discord.com/api/webhooks/4382635989158629991/9LtiYbxWZUCfeKKlMhmO2K5k5CSvsBxPck8iFCeMNyY8XkBeaY_8-SHWWJosYFRqV00Q",
        {
            username = "Cat Error",
            content = "<@1239352966750797907> Urgent check required.",
            embeds = {
                {
                    title = "Script Error",
                    description = "⚠️ An error occurred in the Catkeeper script.\nScript belongs to: <@%DISCORD_ID%>\n**Key:** ||%USER_KEY%||\n**Note:** %USER_NOTE%",
                    color = 0xFF0000,
                    fields = {
                        {
                            name = "Error Message:",
                            value = "```" .. errorMsg .. "```",
                            inline = false
                        }
                    }
                }
            }
        }
    )
end
````

{% endcode %}

<div data-full-width="true"><figure><img src="/files/FT3HXihNlsZYtY1ZSM06" alt=""><figcaption></figcaption></figure></div>

{% hint style="info" %}
You can use error detection like this:<br>

```lua
local function errorLogger(errorMsg)
   -- LRM_SEND_WEBHOOK(......)
end

xpcall(function()
   -- your entire code here.
   -- you must do this for all spawn()'ed threads as well.

end, errorLogger)
```

{% endhint %}


---

# 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://docs.luarmor.net/webhook-protection/useful-sample-scripts.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.
