# Discord Setup

DeathAnnouncer features seamless Discord integration, allowing you to broadcast in-game deaths directly to a Discord channel in real-time. This is achieved using Discord Webhooks, which are lightweight, secure, and require no bot hosting.

Follow the steps below to set up and customize your Discord death logs.

### Step 1: Creating a Discord Webhook

Before configuring the plugin, you need to generate a Webhook URL in your Discord server:

1. Open Discord and navigate to the channel where you want the death messages to appear.
2. Click the **Edit Channel** (gear icon) next to the channel name.
3. Go to the **Integrations** tab in the left sidebar.
4. Click on **Webhooks** and then **New Webhook**.
5. Give your webhook a name (e.g., "Server Deaths") and click **Copy Webhook URL**.
6. Save your changes.

### Step 2: Configuring the Plugin

Once you have the Webhook URL, open the `config.yml` file located in `plugins/DeathAnnouncer/`. Scroll down to the `discord-webhook` section.

Paste your copied URL inside the quotes for the `url` option and set `enabled` to `true`.

```
# --- Discord Webhook ---
# Sends an elegant embed message to a Discord channel when a player dies.
discord-webhook:
  enabled: true
  url: "Paste the Webhook URL"
  username: "DeathAnnouncer"
  avatar-url: ""
```

### Step 3: Customizing the Message

DeathAnnouncer allows you to fully customize how the message looks in Discord. You can use standard text, rich embeds, or a combination of both.

#### Standard Message Content

The `content` field is useful if you want to ping specific roles (like `@here` or `<@&ROLE_ID>`) or if you simply prefer a plain text message without embeds.

```
  message:
    use-embed: true
    content: "" # Text outside the embed
```

#### Rich Embeds

If `use-embed` is set to `true`, the plugin will send a formatted block. You can customize the borders, thumbnails, titles, and fields.

```
  embed:
    title: "Death Log"
    color: "#FF0000" # HEX color code for the embed border
    description: "{emoji} {message}"
    thumbnail: "https://mc-heads.net/avatar/{player}"
    footer-text: "DeathAnnouncer - SpigotMC"
    footer-icon: ""
    fields:
      player:
        name: "Player"
        value: "{player}"
        inline: true
      cause:
        name: "Cause"
        value: "{cause}"
        inline: true
      killer:
        name: "Killer"
        value: "{killer}"
        inline: false
```

* **Color:** Must be a valid HEX color code (e.g., `#FF0000` for red, `#00FF00` for green).
* **Thumbnail:** By default, it uses the `mc-heads.net` API to fetch the 3D head of the victim using the `{player}` placeholder.
* **Inline Fields:** Setting `inline` to `true` places the fields side-by-side. Setting it to `false` forces the field to take up a full row.

### Discord Placeholders

The Discord section has its own set of exclusive placeholders that can be used anywhere within the `discord-webhook` configuration block:

* `{player}` - The name of the victim.
* `{uuid}` - The UUID of the victim.
* `{killer}` - The name of the killer (or "None" if environmental).
* `{weapon}` - The weapon used to kill the player.
* `{cause}` - The technical damage cause.
* `{world}` - The world where the death occurred.
* `{biome}` - The biome where the death occurred.
* `{x}`, `{y}`, `{z}` - The exact coordinates of the death.
* `{ping}` - The victim's ping at the moment of death.
* `{message}` - The formatted death message (as it appeared in-game).
* `{emoji}` - The icon prefix assigned to the death cause (from your language file).

### Troubleshooting

* **No messages in Discord:** Ensure your Webhook URL is pasted correctly inside the quotes and that `enabled` is set to `true`.
* **Invalid Form Body Error in Console:** This usually means one of your embed fields is completely empty or the HEX color is invalid. Make sure every `name` and `value` in your fields has at least one character or a valid placeholder.


---

# Agent Instructions: 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:

```
GET https://plugin-labs.gitbook.io/deathannouncer/getting-started/discord-setup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
