Represents a Discord channel.
Channel types
| Constant | Value | Description |
|---|---|---|
type_guild_text/0 | 0 | Text channel in a guild |
type_dm/0 | 1 | Direct message |
type_guild_voice/0 | 2 | Voice channel in a guild |
type_group_dm/0 | 3 | Group DM |
type_guild_category/0 | 4 | Category |
type_guild_news/0 | 5 | News / announcement channel |
type_guild_news_thread/0 | 10 | Thread in a news channel |
type_guild_public_thread/0 | 11 | Public thread |
type_guild_private_thread/0 | 12 | Private thread |
type_guild_stage_voice/0 | 13 | Stage voice channel |
type_guild_forum/0 | 15 | Forum channel |
type_guild_media/0 | 16 | Media channel |
Forum layout types
| Constant | Value | Description |
|---|---|---|
layout_not_set/0 | 0 | Not set |
layout_list_view/0 | 1 | List view |
layout_gallery_view/0 | 2 | Gallery view |
Sort order types
| Constant | Value | Description |
|---|---|---|
sort_latest_activity/0 | 0 | Latest activity |
sort_creation_date/0 | 1 | Creation date |
Summary
Functions
Applies a changeset to a channel. No-op if the changeset has no changes.
Adds a change to an existing changeset for this entity.
Creates a changeset for batching mutations to this entity.
Deletes a channel.
Fetches a channel by ID. Checks cache first, falls back to REST.
Fetches a channel by ID. Raises on error.
Returns true if the channel is a forum channel (type 15).
Returns 2 — Gallery view layout.
Returns 1 — List view layout.
Returns 0 — Forum layout not set.
Returns true if the channel is a media channel (type 16).
Modifies a channel. Accepts a struct or ID, a map of changes, and options.
Sends a message to a channel. Returns a %EDA.Message{} struct.
Sets a voice channel's status (up to 500 characters, or nil to clear it).
Returns 1 — Sort by creation date.
Returns 0 — Sort by latest activity.
Returns true if the channel is a thread (types 10, 11, 12).
Returns 1 — Direct message.
Returns 3 — Group DM.
Returns 4 — Guild category.
Returns 15 — Forum channel.
Returns 16 — Media channel.
Returns 5 — Guild news/announcement channel.
Returns 10 — Thread in a news channel.
Returns 12 — Private thread.
Returns 11 — Public thread.
Returns 13 — Stage voice channel.
Returns 0 — Guild text channel.
Returns 2 — Guild voice channel.
Types
@type t() :: %EDA.Channel{ applied_tags: [String.t()] | nil, available_tags: [EDA.ForumTag.t()] | nil, bitrate: integer() | nil, default_auto_archive_duration: integer() | nil, default_forum_layout: integer() | nil, default_reaction_emoji: map() | nil, default_sort_order: integer() | nil, default_thread_rate_limit_per_user: integer() | nil, flags: integer() | nil, guild_id: String.t() | nil, id: String.t() | nil, last_message_id: String.t() | nil, member_count: integer() | nil, message_count: integer() | nil, name: String.t() | nil, nsfw: boolean() | nil, owner_id: String.t() | nil, parent_id: String.t() | nil, permission_overwrites: [EDA.PermissionOverwrite.t()] | nil, position: integer() | nil, rate_limit_per_user: integer() | nil, status: String.t() | nil, thread_metadata: map() | nil, topic: String.t() | nil, total_message_sent: integer() | nil, type: integer() | nil, user_limit: integer() | nil }
Functions
@spec apply_changeset( EDA.Entity.Changeset.t(), keyword() ) :: {:ok, t()} | {:error, term()}
Applies a changeset to a channel. No-op if the changeset has no changes.
Options
:reason- Audit log reason
@spec change(EDA.Entity.Changeset.t(), atom(), term()) :: EDA.Entity.Changeset.t()
Adds a change to an existing changeset for this entity.
@spec changeset(t()) :: EDA.Entity.Changeset.t()
Creates a changeset for batching mutations to this entity.
Deletes a channel.
Options
:reason- Audit log reason
Fetches a channel by ID. Checks cache first, falls back to REST.
Fetches a channel by ID. Raises on error.
Returns true if the channel is a forum channel (type 15).
Examples
iex> EDA.Channel.forum?(%EDA.Channel{type: 15})
true
iex> EDA.Channel.forum?(%EDA.Channel{type: 0})
false
Returns 2 — Gallery view layout.
Returns 1 — List view layout.
Returns 0 — Forum layout not set.
Returns true if the channel is a media channel (type 16).
Examples
iex> EDA.Channel.media?(%EDA.Channel{type: 16})
true
iex> EDA.Channel.media?(%EDA.Channel{type: 0})
false
Modifies a channel. Accepts a struct or ID, a map of changes, and options.
Options
:reason- Audit log reason
@spec send_message(t() | String.t() | integer(), String.t() | map() | keyword()) :: {:ok, EDA.Message.t()} | {:error, term()}
Sends a message to a channel. Returns a %EDA.Message{} struct.
@spec set_voice_status(t() | String.t() | integer(), String.t() | nil, keyword()) :: :ok | {:error, term()}
Sets a voice channel's status (up to 500 characters, or nil to clear it).
Accepts a channel struct or ID.
Options
:reason- Audit log reason
Returns 1 — Sort by creation date.
Returns 0 — Sort by latest activity.
Returns true if the channel is a thread (types 10, 11, 12).
Examples
iex> EDA.Channel.thread?(%EDA.Channel{type: 11})
true
iex> EDA.Channel.thread?(%EDA.Channel{type: 0})
false
Returns 1 — Direct message.
Returns 3 — Group DM.
Returns 4 — Guild category.
Returns 15 — Forum channel.
Returns 16 — Media channel.
Returns 5 — Guild news/announcement channel.
Returns 10 — Thread in a news channel.
Returns 12 — Private thread.
Returns 11 — Public thread.
Returns 13 — Stage voice channel.
Returns 0 — Guild text channel.
Returns 2 — Guild voice channel.