REST API endpoints for Discord threads.
All functions return {:ok, result} or {:error, reason}.
Summary
Functions
Adds a member to a thread.
Creates a new forum/media channel post (thread with a starter message).
Gets a thread member object for a user.
Joins a thread.
Leaves a thread.
Lists active threads in a guild.
Lists members of a thread.
Removes a member from a thread.
Starts a thread without a message.
Starts a thread from an existing message.
Functions
Adds a member to a thread.
Creates a new forum/media channel post (thread with a starter message).
Discord's POST /channels/{channel_id}/threads for forum channels requires
a message object in the body. At least one of :content, :embeds,
:sticker_ids, or :files must be provided in message_opts.
Parameters
channel_id— the forum or media channel IDopts— thread options::name(required) — thread name (1–100 characters):auto_archive_duration— minutes before auto-archive (60, 1440, 4320, 10080):rate_limit_per_user— slowmode in seconds (0–21600):applied_tags— list of tag ID strings to apply (max 5)
message_opts— starter message content::content— text content:embeds— list of embeds:embed— single embed (convenience, cannot combine with:embeds):components— message components:sticker_ids— list of sticker IDs:files— list of files (enables multipart upload):file— single file (convenience, cannot combine with:files):allowed_mentions— allowed mentions object
Examples
# Simple text post
Thread.create_post("forum_id", [name: "Help needed"], content: "How do I…?")
# Post with tags and an embed
Thread.create_post("forum_id",
[name: "Bug Report", applied_tags: ["tag1", "tag2"]],
content: "Found a bug", embeds: [%{title: "Details"}]
)
# Post with file attachment
Thread.create_post("forum_id",
[name: "Screenshot"],
content: "See attached", file: "path/to/image.png"
)
Gets a thread member object for a user.
Examples
{:ok, member} = Thread.get_member(thread_id, user_id)
Joins a thread.
Leaves a thread.
Lists active threads in a guild.
Lists members of a thread.
Examples
{:ok, members} = Thread.list_members(thread_id)
Removes a member from a thread.
Examples
:ok = Thread.remove_member(thread_id, user_id)
Starts a thread without a message.
@spec start_from_message(String.t() | integer(), String.t() | integer(), map()) :: {:ok, map()} | {:error, term()}
Starts a thread from an existing message.