# `Noizu.Discord.Webhooks`
[🔗](https://github.com/noizu-labs-sdks/elixir-discord/blob/v0.1.0/lib/noizu/discord/webhooks.ex#L1)

Webhook endpoints.

`execute/3` needs no bot token — the webhook token in the URL is the credential.
Treat webhook URLs as secrets.

# `target`

```elixir
@type target() :: String.t() | {String.t(), String.t()}
```

# `create`

```elixir
@spec create(Noizu.Discord.Client.t(), String.t(), map(), keyword()) ::
  Noizu.Discord.Request.result()
```

POST /channels/{channel.id}/webhooks — create a webhook. `params`: `%{name, avatar}`.
Accepts `:reason` (audit log).

# `execute`

```elixir
@spec execute(target(), map(), keyword()) :: Noizu.Discord.Request.result()
```

POST /webhooks/{webhook.id}/{webhook.token} — execute a webhook.

`target` is a full webhook URL (`https://discord.com/api/webhooks/<id>/<token>`) or
an `{id, token}` tuple. `params`: `%{content, embeds, username, avatar_url,
thread_id, allowed_mentions, components, thread_name, flags}` — `thread_id` is sent
as a query parameter as Discord requires.

Opts:
  * `:wait` — default `true` (Discord returns the created message); `false` returns
    `{:ok, nil}`.
  * `:client` — a `Noizu.Discord.Client` whose `base_url`, `user_agent`,
    `req_options` and `retry` are used (its token is never sent). Without it a
    client is built from `:base_url` / `:req_options` / `:retry` opts.
  * `:meta`.

The request always goes to the client's `base_url`; only id + token are taken
from a URL target.

# `list_channel`

```elixir
@spec list_channel(Noizu.Discord.Client.t(), String.t(), keyword()) ::
  Noizu.Discord.Request.result()
```

GET /channels/{channel.id}/webhooks — the channel's webhooks.

# `parse_target`

```elixir
@spec parse_target(target()) ::
  {:ok, {String.t(), String.t()}} | {:error, Noizu.Discord.Error.t()}
```

Parses a webhook URL or `{id, token}` into `{:ok, {id, token}}`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
