> ## Documentation Index
> Fetch the complete documentation index at: https://docs.erlc.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Automate ERLC Discord Moderation in erlc.dev Studio

> Build moderation automations that auto-timeout high-wanted players, log mod actions, and respond to AutoMod triggers using erlc.dev Studio.

Keeping your ERLC Discord server safe is a constant job, but erlc.dev Studio lets you offload much of the routine work to automated block chains. This guide walks you through three moderation automations: auto-timing-out players with high wanted levels, logging kick commands to a mod channel, and responding to Discord's built-in AutoMod when it catches a rule violation.

<Note>
  All three automations require a connected Discord bot with appropriate permissions (**Moderate Members**, **Manage Messages**, **Send Messages**). Make sure your bot is linked under **Settings → Bot** before you begin.
</Note>

***

## Part 1: Auto-timeout high-wanted players

When a player accumulates more than three wanted stars in-game, this automation automatically times them out on Discord for five minutes, giving your moderation team time to respond.

<Steps>
  <Step title="Add the ERLC event trigger">
    Drag an **`erlc_when_event`** block onto the canvas and set its **EVENT** field to **`player_wanted_level_changed`**. This block fires every time a player's wanted level changes in your ERLC server.
  </Step>

  <Step title="Read the player ID and wanted stars">
    Attach two **`erlc_event_value`** blocks to read data from the event:

    * First block — set **FIELD** to **`PlayerId`** to get the Roblox user ID.
    * Second block — set **FIELD** to **`WantedStars`** to get the current wanted level (a number from 0–5).

    Store both values by wiring them into the inputs of the blocks that follow.
  </Step>

  <Step title="Convert Roblox ID to Discord ID">
    Attach an **`erlc_roblox_discord_id`** block and wire the output of your `PlayerId` `erlc_event_value` block into its **ROBLOX\_ID** input. This block looks up the linked Discord account for the given Roblox user.
  </Step>

  <Step title="Check if wanted stars exceed the threshold">
    Attach an **`erlc_compare_values`** block. Set the comparison operator to **`>`** (greater than). Wire:

    * The **`WantedStars`** `erlc_event_value` output into the **A** input.
    * An **`erlc_text_value`** block with value **`3`** into the **B** input.
  </Step>

  <Step title="Apply the timeout inside a conditional">
    Attach an **`erlc_if_else`** block and connect the comparison block into its **CONDITION** input. Inside the **THEN** branch, attach an **`erlc_bot_timeout`** block:

    * Wire the output of `erlc_roblox_discord_id` into the **USER\_ID** input.
    * Set **SECONDS** to **`300`** (five minutes).
  </Step>
</Steps>

### Part 1 block JSON

Paste this into **File → Import Blocks** and replace `<resource-id>` where applicable.

```json theme={null}
{
  "format": "erlc-studio-blocks",
  "version": 1,
  "workspace": {
    "blocks": {
      "languageVersion": 0,
      "blocks": [
        {
          "type": "erlc_when_event",
          "id": "event_p1",
          "x": 48,
          "y": 48,
          "fields": {
            "EVENT": "player_wanted_level_changed"
          },
          "next": {
            "block": {
              "type": "erlc_if_else",
              "id": "action_if_1",
              "inputs": {
                "CONDITION": {
                  "block": {
                    "type": "erlc_compare_values",
                    "id": "val_compare_1",
                    "fields": {
                      "OPERATOR": ">"
                    },
                    "inputs": {
                      "A": {
                        "block": {
                          "type": "erlc_event_value",
                          "id": "val_stars_1",
                          "fields": {
                            "FIELD": "WantedStars"
                          }
                        }
                      },
                      "B": {
                        "block": {
                          "type": "erlc_text_value",
                          "id": "val_threshold_1",
                          "fields": {
                            "VALUE": "3"
                          }
                        }
                      }
                    }
                  }
                },
                "THEN": {
                  "block": {
                    "type": "erlc_bot_timeout",
                    "id": "action_timeout_1",
                    "inputs": {
                      "USER_ID": {
                        "block": {
                          "type": "erlc_roblox_discord_id",
                          "id": "val_discord_id_1",
                          "inputs": {
                            "ROBLOX_ID": {
                              "block": {
                                "type": "erlc_event_value",
                                "id": "val_player_id_1",
                                "fields": {
                                  "FIELD": "PlayerId"
                                }
                              }
                            }
                          }
                        }
                      },
                      "SECONDS": {
                        "block": {
                          "type": "erlc_text_value",
                          "id": "val_seconds_1",
                          "fields": {
                            "VALUE": "300"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      ]
    }
  }
}
```

<Warning>
  `erlc_roblox_discord_id` only works if the player has linked their Roblox and Discord accounts through your server's verification system. If no link exists, the block returns an empty value and the timeout block will skip.
</Warning>

***

## Part 2: Log kick commands to a mod channel

This automation watches for any ERLC command that contains the word "kick" and forwards a summary to your mod-log channel in Discord.

<Steps>
  <Step title="Add the command-run trigger">
    Drag an **`erlc_when_event`** block onto the canvas and set **EVENT** to **`command_run`**. This fires whenever any command is executed in your ERLC server.
  </Step>

  <Step title="Read the command name">
    Attach an **`erlc_event_value`** block with **FIELD** set to **`CommandName`**. This gives you the name of the command that was run.
  </Step>

  <Step title="Check if the command is a kick">
    Attach an **`erlc_compare_values`** block. Set the operator to **`contains`**. Wire:

    * The `CommandName` `erlc_event_value` output into the **A** input.
    * An **`erlc_text_value`** block with value **`kick`** into the **B** input.
  </Step>

  <Step title="Read the target player">
    Inside the **THEN** branch of an **`erlc_if_else`** block, attach an **`erlc_event_value`** block with **FIELD** set to **`TargetName`** (or the relevant field your server emits for the kick target).
  </Step>

  <Step title="Send a mod-log message">
    Attach an **`erlc_bot_send_message`** block inside the **THEN** branch:

    * Set **CHANNEL\_ID** to your mod-log channel ID (`<resource-id>`).
    * Wire an **`erlc_join_values`** chain into **MESSAGE** to build a string like:
      `"🔨 Kick command run — Target: "` + `TargetName` value.
  </Step>
</Steps>

<Tip>
  Add a second `erlc_event_value` block for **`ExecutorName`** and include it in the log message so moderators know who ran the command.
</Tip>

***

## Part 3: Auto-respond to AutoMod actions

Discord's AutoMod can flag messages automatically, but it won't DM the offending user. This automation bridges that gap by sending a warning DM whenever AutoMod fires.

<Steps>
  <Step title="Add the AutoMod trigger">
    Drag an **`erlc_when_discord_event`** block onto the canvas and set **EVENT** to **`discord_automod_action`**. This fires whenever Discord's AutoMod takes action on a message in your server.
  </Step>

  <Step title="Read the matched keyword and user ID">
    Attach two **`erlc_discord_event_value`** blocks:

    * First block — set **FIELD** to **`MatchedKeyword`** to capture what word triggered AutoMod.
    * Second block — set **FIELD** to **`DiscordUserId`** to identify who sent the message.
  </Step>

  <Step title="Send a warning DM">
    Attach an **`erlc_bot_dm_user`** block:

    * Wire the `DiscordUserId` value into **USER\_ID**.
    * Build a message using **`erlc_join_values`**:
      `"⚠️ Your message was flagged by AutoMod for the keyword: "` + `MatchedKeyword` value + `". Please review the server rules."`
  </Step>
</Steps>

<Info>
  The `discord_automod_action` event fires for every AutoMod rule type (keyword filter, spam detection, mention spam, etc.). If you only want to respond to keyword violations, add an `erlc_compare_values` check on the **`RuleType`** field before sending the DM.
</Info>

***

## Automation summary

| Automation | Trigger | Key blocks |
| - | - | - |
| Auto-timeout | `player_wanted_level_changed` | `erlc_roblox_discord_id`, `erlc_compare_values`, `erlc_bot_timeout` |
| Kick log | `command_run` | `erlc_compare_values` (contains), `erlc_bot_send_message` |
| AutoMod DM | `discord_automod_action` | `erlc_discord_event_value`, `erlc_bot_dm_user` |

<CardGroup cols={2}>
  <Card title="Welcome Bot" icon="hand-wave" href="/guides/welcome-bot">
    Greet new members and assign roles automatically.
  </Card>

  <Card title="Event Logging" icon="scroll" href="/guides/logging-events">
    Post kill logs and join/leave events to Discord channels.
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.