# 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="https://3136584356-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwOpQH2LpMjsOwgeFM5gE%2Fuploads%2F8Vn1wRX4nZazleDiqlrR%2Fimage.png?alt=media&#x26;token=94f96b3c-86de-4b42-97b8-0d9105df5a46" 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="https://3136584356-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwOpQH2LpMjsOwgeFM5gE%2Fuploads%2FhfeyH6Ar7Ucai4ySfIbX%2Fimage.png?alt=media&#x26;token=d14a517f-5548-4358-8e3b-c5b930516ec4" 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="https://3136584356-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwOpQH2LpMjsOwgeFM5gE%2Fuploads%2FyiRclJ6qtn5OeDrS4I8P%2Fimage.png?alt=media&#x26;token=a82b8ed9-a532-4aae-b4b7-c79f821165f1" 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="https://3136584356-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwOpQH2LpMjsOwgeFM5gE%2Fuploads%2FSoa6iuX50DOI5fYZBB7z%2Fimage.png?alt=media&#x26;token=8415e686-761f-4bfe-afd6-1ccc6d3ed170" 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 %}
