Represents a tag available in a Discord Forum or Media channel.
Forum tags can be applied to threads (posts) within a forum channel to help organize discussions. Each tag has a name, an optional emoji, and a moderated flag that restricts who can apply it.
Existing vs new tags
Tags returned from the Discord API have an id (snowflake string).
Tags you create programmatically with new/2 have id: nil — Discord
assigns the ID when the channel is updated with the new tag list.
Examples
# Parse a tag from Discord API data
tag = EDA.ForumTag.from_raw(%{
"id" => "123456",
"name" => "Resolved",
"moderated" => true,
"emoji_id" => nil,
"emoji_name" => "✅"
})
# Create a new tag programmatically
tag = EDA.ForumTag.new("Bug Report", moderated: true, emoji: "🐛")
# Serialize for API (e.g. updating available_tags on a channel)
EDA.ForumTag.to_raw(tag)
Summary
Functions
Parses a forum tag from a raw Discord API map.
Creates a new forum tag struct (without an ID).
Serializes a forum tag for the Discord API.
Types
Functions
Parses a forum tag from a raw Discord API map.
Examples
iex> EDA.ForumTag.from_raw(%{"id" => "1", "name" => "Bug", "moderated" => false, "emoji_id" => nil, "emoji_name" => "🐛"})
%EDA.ForumTag{id: "1", name: "Bug", moderated: false, emoji_id: nil, emoji_name: "🐛"}
Creates a new forum tag struct (without an ID).
Options
:moderated- iftrue, only users withMANAGE_THREADScan apply this tag. Defaults tofalse.:emoji- anEDA.Emojistruct or a unicode string (e.g."🐛").
Examples
iex> EDA.ForumTag.new("Help")
%EDA.ForumTag{name: "Help", moderated: false}
iex> EDA.ForumTag.new("Bug", moderated: true, emoji: "🐛")
%EDA.ForumTag{name: "Bug", moderated: true, emoji_name: "🐛"}
iex> EDA.ForumTag.new("Cool", emoji: %EDA.Emoji{id: "99", name: "cool"})
%EDA.ForumTag{name: "Cool", moderated: false, emoji_id: "99", emoji_name: "cool"}
Serializes a forum tag for the Discord API.
Omits keys with nil values so Discord doesn't receive explicit nulls.
Examples
iex> tag = %EDA.ForumTag{id: "1", name: "Bug", moderated: false, emoji_name: "🐛"}
iex> EDA.ForumTag.to_raw(tag)
%{"id" => "1", "name" => "Bug", "moderated" => false, "emoji_name" => "🐛"}