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 the private archived threads of a channel that the bot has joined, newest id first.
Needs READ_MESSAGE_HISTORY.
Lists members of a thread.
Lists a channel's private archived threads, most recently archived first. Needs
READ_MESSAGE_HISTORY and MANAGE_THREADS. Same options and answer as
list_public_archived/2.
Lists a channel's public archived threads, most recently archived first.
Removes a member from a thread.
Starts a thread without a message.
Starts a thread from an existing message.
Streams a channel's archived threads, lazily, page after page.
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.
@spec list_joined_private_archived( String.t() | integer(), keyword() ) :: {:ok, map()} | {:error, term()}
Lists the private archived threads of a channel that the bot has joined, newest id first.
Needs READ_MESSAGE_HISTORY.
Same answer as list_public_archived/2, but :before is a thread id here, not a time.
Lists members of a thread.
Examples
{:ok, members} = Thread.list_members(thread_id)
Lists a channel's private archived threads, most recently archived first. Needs
READ_MESSAGE_HISTORY and MANAGE_THREADS. Same options and answer as
list_public_archived/2.
Lists a channel's public archived threads, most recently archived first.
GET /channels/{channel_id}/threads/archived/public. Answers
%{"threads" => [...], "members" => [...], "has_more" => boolean} — members holds the
bot's own thread member for each thread it joined. Needs READ_MESSAGE_HISTORY.
Options
:before— threads archived before this time, aDateTimeor an ISO8601 string:limit— how many to return
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() | keyword() ) :: {:ok, map()} | {:error, term()}
Starts a thread from an existing message.
@spec stream_archived( String.t() | integer(), :public | :private | :joined_private, keyword() ) :: Enumerable.t()
Streams a channel's archived threads, lazily, page after page.
kind is :public, :private or :joined_private. Pages follow Discord's own cursor for
each kind — the archive time, or the thread id for joined private threads.
EDA.API.Thread.stream_archived(channel_id, :public) |> Enum.take(250)