EDA.API.Thread (EDA v0.3.0)

Copy Markdown View Source

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

add_member(channel_id, user_id)

@spec add_member(String.t() | integer(), String.t() | integer()) ::
  :ok | {:error, term()}

Adds a member to a thread.

create_post(channel_id, opts, message_opts \\ [])

@spec create_post(String.t() | integer(), keyword(), keyword()) ::
  {:ok, map()} | {:error, term()}

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 ID
  • opts — 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"
)

get_member(channel_id, user_id)

@spec get_member(String.t() | integer(), String.t() | integer()) ::
  {:ok, map()} | {:error, term()}

Gets a thread member object for a user.

Examples

{:ok, member} = Thread.get_member(thread_id, user_id)

join(channel_id)

@spec join(String.t() | integer()) :: :ok | {:error, term()}

Joins a thread.

leave(channel_id)

@spec leave(String.t() | integer()) :: :ok | {:error, term()}

Leaves a thread.

list_active(guild_id)

@spec list_active(String.t() | integer()) :: {:ok, map()} | {:error, term()}

Lists active threads in a guild.

list_members(channel_id)

@spec list_members(String.t() | integer()) :: {:ok, [map()]} | {:error, term()}

Lists members of a thread.

Examples

{:ok, members} = Thread.list_members(thread_id)

remove_member(channel_id, user_id)

@spec remove_member(String.t() | integer(), String.t() | integer()) ::
  :ok | {:error, term()}

Removes a member from a thread.

Examples

:ok = Thread.remove_member(thread_id, user_id)

start(channel_id, opts)

@spec start(String.t() | integer(), map()) :: {:ok, map()} | {:error, term()}

Starts a thread without a message.

start_from_message(channel_id, message_id, opts)

@spec start_from_message(String.t() | integer(), String.t() | integer(), map()) ::
  {:ok, map()} | {:error, term()}

Starts a thread from an existing message.