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

Channel, message, thread, typing and pin endpoints.

Message params (`create_message/4`, `edit_message/5`) are passed through as JSON:
`content`, `embeds`, `components`, `message_reference`, `allowed_mentions`, `flags`,
… Build embeds with `Noizu.Discord.Embeds` and convert/split long markdown with
`Noizu.Discord.Markdown`.

# `create_message`

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

POST /channels/{channel.id}/messages — send a message.

`params`: `%{content, embeds, components, message_reference, allowed_mentions, …}`
(atom or string keys). Content is limited to 2000 characters — see
`Noizu.Discord.Markdown.chunk/2`.

# `delete_message`

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

DELETE /channels/{channel.id}/messages/{message.id} — delete a message (`{:ok, nil}`).

# `edit_message`

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

PATCH /channels/{channel.id}/messages/{message.id} — edit a message.

# `get`

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

GET /channels/{channel.id} — a channel (or thread) by id.

# `get_message`

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

GET /channels/{channel.id}/messages/{message.id} — one message.

# `list_active_threads`

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

GET /guilds/{guild.id}/threads/active — all active threads in a **guild**
(`%{"threads" => [...], "members" => [...]}`). Note the argument is a guild id:
API v10 has no per-channel active-threads endpoint.

# `messages`

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

GET /channels/{channel.id}/messages — one page of messages (newest first).
Query opts: `:before`, `:after`, `:around` (mutually exclusive), `:limit` (1–100).

# `messages_stream`

```elixir
@spec messages_stream(Noizu.Discord.Client.t(), String.t(), keyword()) ::
  Enumerable.t()
```

GET /channels/{channel.id}/messages — lazy stream over history.

Default walks backwards from the newest message (`before` paging; pass `:before`
to start below a given id). Pass `:after` to walk forwards from that id instead.
`:limit` is the page size (default 100). `:around` is not supported for streams.

# `pin_message`

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

PUT /channels/{channel.id}/messages/pins/{message.id} — pin a message (`{:ok, nil}`).
Accepts `:reason` (audit log).

# `start_thread`

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

POST /channels/{channel.id}/threads — start a thread without a message.
`params`: `%{name, type, auto_archive_duration, invitable, rate_limit_per_user}`
(forum/media channels also take `message`).

# `start_thread_from_message`

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

POST /channels/{channel.id}/messages/{message.id}/threads — start a thread from a
message. `params`: `%{name, auto_archive_duration, rate_limit_per_user}`.

# `typing`

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

POST /channels/{channel.id}/typing — trigger the typing indicator (`{:ok, nil}`).

---

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