> ## 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.

# Log ERLC Game Events to Discord in erlc.dev Studio

> Post kill logs, join logs, and command logs to your Discord server automatically using erlc.dev Studio event triggers and Discord message blocks.

Visibility into what's happening inside your ERLC server makes moderation faster and your community more transparent. With erlc.dev Studio you can pipe raw game events — kills, joins, leaves — directly into dedicated Discord channels as neatly formatted messages, all without touching a single line of code. This guide covers three logging automations and finishes with a bonus rich-embed kill log.

<Tip>
  If your server is busy and events fire rapidly, attach an **`erlc_throttle`** block between your trigger and your `erlc_bot_send_message` block. Throttling limits how often the automation can post, preventing a flood of messages that could get your bot rate-limited or mute a channel for legitimate chats.
</Tip>

***

## Part 1: Kill log

Every time a player is killed in ERLC, this automation posts a line to your `#kill-log` channel showing who did it, who died, and when.

<Steps>
  <Step title="Add the player-killed trigger">
    Drag an **`erlc_when_event`** block onto the canvas and set **EVENT** to **`player_killed`**. This fires once per kill event in your ERLC server.
  </Step>

  <Step title="Read kill event data">
    Attach three **`erlc_event_value`** blocks to pull the relevant fields:

    * **`KillerName`** — the display name of the player who scored the kill.
    * **`KilledName`** — the display name of the player who was eliminated.
    * **`Timestamp`** — the time the kill occurred (ISO 8601 string).
  </Step>

  <Step title="Build the log message">
    Use nested **`erlc_join_values`** blocks to concatenate the fields into a readable log line:

    ```
    "💀 " + KillerName + " eliminated " + KilledName + " at " + Timestamp
    ```
  </Step>

  <Step title="Send to the kill-log channel">
    Attach an **`erlc_bot_send_message`** block:

    * Set **CHANNEL\_ID** to your `#kill-log` channel ID (replace `<resource-id>`).
    * Wire your completed `erlc_join_values` chain into the **MESSAGE** input.
  </Step>
</Steps>

### Part 1 block JSON

```json theme={null}
{
  "format": "erlc-studio-blocks",
  "version": 1,
  "workspace": {
    "blocks": {
      "languageVersion": 0,
      "blocks": [
        {
          "type": "erlc_when_event",
          "id": "event_kill_1",
          "x": 48,
          "y": 48,
          "fields": {
            "EVENT": "player_killed"
          },
          "next": {
            "block": {
              "type": "erlc_bot_send_message",
              "id": "action_send_kill_1",
              "inputs": {
                "CHANNEL_ID": {
                  "block": {
                    "type": "erlc_text_value",
                    "id": "val_channel_kill_1",
                    "fields": {
                      "VALUE": "<resource-id>"
                    }
                  }
                },
                "MESSAGE": {
                  "block": {
                    "type": "erlc_join_values",
                    "id": "val_join_kill_1",
                    "inputs": {
                      "A": {
                        "block": {
                          "type": "erlc_join_values",
                          "id": "val_join_kill_2",
                          "inputs": {
                            "A": {
                              "block": {
                                "type": "erlc_join_values",
                                "id": "val_join_kill_3",
                                "inputs": {
                                  "A": {
                                    "block": {
                                      "type": "erlc_join_values",
                                      "id": "val_join_kill_4",
                                      "inputs": {
                                        "A": {
                                          "block": {
                                            "type": "erlc_text_value",
                                            "id": "val_skull",
                                            "fields": {
                                              "VALUE": "💀 "
                                            }
                                          }
                                        },
                                        "B": {
                                          "block": {
                                            "type": "erlc_event_value",
                                            "id": "val_killer_name",
                                            "fields": {
                                              "FIELD": "KillerName"
                                            }
                                          }
                                        }
                                      }
                                    }
                                  },
                                  "B": {
                                    "block": {
                                      "type": "erlc_text_value",
                                      "id": "val_eliminated",
                                      "fields": {
                                        "VALUE": " eliminated "
                                      }
                                    }
                                  }
                                }
                              }
                            },
                            "B": {
                              "block": {
                                "type": "erlc_event_value",
                                "id": "val_killed_name",
                                "fields": {
                                  "FIELD": "KilledName"
                                }
                              }
                            }
                          }
                        }
                      },
                      "B": {
                        "block": {
                          "type": "erlc_join_values",
                          "id": "val_join_kill_5",
                          "inputs": {
                            "A": {
                              "block": {
                                "type": "erlc_text_value",
                                "id": "val_at",
                                "fields": {
                                  "VALUE": " at "
                                }
                              }
                            },
                            "B": {
                              "block": {
                                "type": "erlc_event_value",
                                "id": "val_timestamp",
                                "fields": {
                                  "FIELD": "Timestamp"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      ]
    }
  }
}
```

***

## Part 2: Join/leave log

This automation handles both player joins and leaves using a single trigger and an `erlc_if_else` block to branch the message based on the `Join` field.

<Steps>
  <Step title="Add the player-joined trigger">
    Drag an **`erlc_when_event`** block onto the canvas and set **EVENT** to **`player_joined`**. This event fires for both joins and leaves — the `Join` field tells you which one it is.
  </Step>

  <Step title="Read event fields">
    Attach three **`erlc_event_value`** blocks:

    * **`PlayerName`** — the display name of the player.
    * **`Join`** — a boolean (`true` when joining, `false` when leaving).
    * **`Timestamp`** — the time of the event.
  </Step>

  <Step title="Branch on the Join field">
    Attach an **`erlc_if_else`** block and wire the **`Join`** `erlc_event_value` output into its **CONDITION** input.

    **THEN branch (join):** Attach an **`erlc_bot_send_message`** block with a message like:
    `"✅ " + PlayerName + " joined the server at " + Timestamp`

    **ELSE branch (leave):** Attach another **`erlc_bot_send_message`** block with a message like:
    `"👋 " + PlayerName + " left the server at " + Timestamp`

    Set the **CHANNEL\_ID** on both send blocks to your `#join-log` channel ID (`<resource-id>`).
  </Step>
</Steps>

<Info>
  If you want join and leave events in separate channels, use two different `<resource-id>` channel IDs — one in the **THEN** branch and one in the **ELSE** branch.
</Info>

***

## Part 3: Rich embed kill log (bonus)

Plain text logs are functional, but an embedded message with a red color, labeled fields, and a timestamp looks much sharper in Discord. This bonus section upgrades your kill log to a rich embed.

<Steps>
  <Step title="Swap the send block for an embed block">
    Replace `erlc_bot_send_message` with an **`erlc_embed_send`** block. This block accepts a **CHANNEL\_ID** and an **EMBED** input that you build from embed component blocks.
  </Step>

  <Step title="Set the embed title">
    Attach an **`erlc_embed_title`** block to the **EMBED** input and set its text to **`"Player Killed"`**.
  </Step>

  <Step title="Add killer and killed fields">
    Chain two **`erlc_embed_field`** blocks:

    * First: **NAME** = `"Killer"`, **VALUE** = output of `erlc_event_value` (FIELD: `KillerName`).
    * Second: **NAME** = `"Killed"`, **VALUE** = output of `erlc_event_value` (FIELD: `KilledName`).
  </Step>

  <Step title="Set a red color">
    Attach an **`erlc_embed_color`** block and wire an **`erlc_discord_rgb`** block into it. Set the RGB values to **R: 255, G: 0, B: 0** for a bold red sidebar on your embed.
  </Step>

  <Step title="Add a timestamp">
    Attach an **`erlc_embed_timestamp`** block to automatically stamp the embed with the current time. This shows up as a relative timestamp (e.g. "just now") in Discord.
  </Step>

  <Step title="Set the channel and save">
    On the `erlc_embed_send` block, set **CHANNEL\_ID** to your `#kill-log` channel ID (`<resource-id>`). Save and enable the automation.
  </Step>
</Steps>

***

## Logging system overview

| Log type | Trigger event | Output channel | Key blocks |
| - | - | - | - |
| Kill log | `player_killed` | `#kill-log` | `erlc_event_value`, `erlc_join_values`, `erlc_bot_send_message` |
| Join/leave log | `player_joined` | `#join-log` | `erlc_event_value`, `erlc_if_else`, `erlc_bot_send_message` |
| Rich embed kill log | `player_killed` | `#kill-log` | `erlc_embed_send`, `erlc_embed_title`, `erlc_embed_field`, `erlc_embed_color`, `erlc_discord_rgb`, `erlc_embed_timestamp` |

<CardGroup cols={2}>
  <Card title="Moderation Automation" icon="shield-halved" href="/guides/moderation-automation">
    Auto-timeout high-wanted players and respond to AutoMod.
  </Card>

  <Card title="Slash Commands" icon="terminal" href="/guides/slash-command-bot">
    Build interactive slash commands for your Discord server.
  </Card>
</CardGroup>


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