View Source Nostrum.Api.Thread (Nostrum v0.10.4)
Functions for interacting with the Discord API's thread endpoints.
Endpoints related to threads in the Discord Channels API: https://discord.com/developers/docs/resources/channel#start-thread-from-message
Summary
Functions
Add a user to a thread, requires the ability to send messages in the thread.
Create a thread on a channel without an associated message.
Create a new thread in a forum channel.
Create a thread on a channel message.
Join an existing thread, requires that the thread is not archived.
Same as public_archived_threads/2, but only returns private threads that the current user has joined.
Leave a thread, requires that the thread is not archived.
Return all active threads for the current guild.
Returns a thread member object for the specified user if they are a member of the thread
Returns a list of thread members for the specified thread.
Same as public_archived_threads/2, but for private threads instead of public.
Returns a list of archived threads for a given channel.
Removes another user from a thread, requires that the thread is not archived.
Types
@type thread_with_message_params() :: %{ :name => String.t(), optional(:auto_archive_duration) => 60 | 1440 | 4320 | 10080, optional(:rate_limit_per_user) => 0..21600 }
@type thread_without_message_params() :: %{ :name => String.t(), :type => non_neg_integer(), optional(:auto_archive_duration) => 60 | 1440 | 4320 | 10080, optional(:invitable) => boolean(), optional(:rate_limit_per_user) => 0..21600 }
Functions
@spec add_member(Nostrum.Struct.Channel.id(), Nostrum.Struct.User.id()) :: {:ok} | Nostrum.Api.error()
Add a user to a thread, requires the ability to send messages in the thread.
@spec create( Nostrum.Struct.Channel.id(), thread_without_message_params(), Nostrum.Struct.Guild.AuditLogEntry.reason() ) :: {:ok, Nostrum.Struct.Channel.t()} | Nostrum.Api.error()
Create a thread on a channel without an associated message.
If successful, returns {:ok, Channel}. Otherwise returns a Nostrum.Api.error/0.
An optional reason argument can be given for the audit log.
Options
name: Name of the thread, max 100 characters.type: Type of thread, can be either 11 (GUILD_PUBLIC_THREAD) or 12 (GUILD_PRIVATE_THREAD).auto_archive_duration: Duration in minutes to auto-archive the thread after it has been inactive, can be set to 60, 1440, 4320, or 10080.invitable: whether non-moderators can add other non-moderators to a thread; only available when creating a private thread defaults tofalse.rate_limit_per_user: Rate limit per user in seconds, can be set to any value in0..21600.
@spec create_in_forum( Nostrum.Struct.Channel.id(), map(), Nostrum.Struct.Guild.AuditLogEntry.reason() ) :: {:ok, Nostrum.Struct.Channel.t()} | Nostrum.Api.error()
Create a new thread in a forum channel.
If successful, returns {:ok, Channel}. Otherwise returns a Nostrum.Api.error/0.
An optional reason argument can be given for the audit log.
Options
name: Name of the thread, max 100 characters.auto_archive_duration: Duration in minutes to auto-archive the thread after it has been inactive, can be set to 60, 1440, 4320, or 10080.rate_limit_per_user: Rate limit per user in seconds, can be set to any value in0..21600.applied_tags: An array of tag ids to apply to the thread.message: The first message in the created thread.
Thread Message Options
content: The content of the message.embeds: A list of embeds.allowed_mentions: Allowed mentions object.components: A list of components.sticker_ids: A list of sticker ids.:files- a list of files where each element is the same format as the:fileoption. If both:fileand:filesare specified,:filewill be prepended to the:fileslist.
At least one of content, embeds, sticker_ids, or files must be specified.
create_with_message(channel_id, message_id, options, reason \\ nil)
View Source (since 1.x.x)@spec create_with_message( Nostrum.Struct.Channel.id(), Nostrum.Struct.Message.id(), thread_with_message_params(), Nostrum.Struct.Guild.AuditLogEntry.reason() ) :: {:ok, Nostrum.Struct.Channel.t()} | Nostrum.Api.error()
Create a thread on a channel message.
The thread_id will be the same as the id of the message, as such no message can have more than one thread.
If successful, returns {:ok, Channel}. Otherwise returns a Nostrum.Api.error/0.
An optional reason argument can be given for the audit log.
Options
name: Name of the thread, max 100 characters.auto_archive_duration: Duration in minutes to auto-archive the thread after it has been inactive, can be set to 60, 1440, 4320, or 10080.rate_limit_per_user: Rate limit per user in seconds, can be set to any value in0..21600.
@spec join(Nostrum.Struct.Channel.id()) :: {:ok} | Nostrum.Api.error()
Join an existing thread, requires that the thread is not archived.
joined_private_archived_threads(channel_id, options \\ [])
View Source (since 1.x.x)@spec joined_private_archived_threads( Nostrum.Struct.Channel.id(), Nostrum.Api.options() ) :: {:ok, %{ threads: [Nostrum.Struct.Channel.t()], members: [Nostrum.Struct.ThreadMember.t()], has_more: boolean() }} | Nostrum.Api.error()
Same as public_archived_threads/2, but only returns private threads that the current user has joined.
@spec leave(Nostrum.Struct.Channel.id()) :: {:ok} | Nostrum.Api.error()
Leave a thread, requires that the thread is not archived.
@spec list(Nostrum.Struct.Guild.id()) :: {:ok, %{ threads: [Nostrum.Struct.Channel.t()], members: [Nostrum.Struct.ThreadMember.t()] }} | Nostrum.Api.error()
Return all active threads for the current guild.
Response body is a map with the following keys:
threads: A list of channel objects.members: A list ofThreadMemberobjects, one for each returned thread the current user has joined.
@spec member(Nostrum.Struct.Channel.id(), Nostrum.Struct.User.id()) :: {:ok, Nostrum.Struct.ThreadMember.t()} | Nostrum.Api.error()
Returns a thread member object for the specified user if they are a member of the thread
@spec members(Nostrum.Struct.Channel.id()) :: {:ok, [Nostrum.Struct.ThreadMember.t()]} | Nostrum.Api.error()
Returns a list of thread members for the specified thread.
This endpoint is restricted according to whether the GUILD_MEMBERS privileged intent is enabled.
@spec private_archived_threads(Nostrum.Struct.Channel.id(), Nostrum.Api.options()) :: {:ok, %{ threads: [Nostrum.Struct.Channel.t()], members: [Nostrum.Struct.ThreadMember.t()], has_more: boolean() }} | Nostrum.Api.error()
Same as public_archived_threads/2, but for private threads instead of public.
@spec public_archived_threads(Nostrum.Struct.Channel.id(), Nostrum.Api.options()) :: {:ok, %{ threads: [Nostrum.Struct.Channel.t()], members: [Nostrum.Struct.ThreadMember.t()], has_more: boolean() }} | Nostrum.Api.error()
Returns a list of archived threads for a given channel.
Threads are sorted by the archive_timestamp field, in descending order.
Response body
Response body is a map with the following keys:
threads: A list of channel objects.members: A list ofThreadMemberobjects, one for each returned thread the current user has joined.has_more: A boolean indicating whether there are more archived threads that can be fetched.
Options
before: Returns threads before this timestamp, can be either aDateTimeor ISO8601 timestamp.limit: Optional maximum number of threads to return.
@spec remove_member(Nostrum.Struct.Channel.id(), Nostrum.Struct.User.id()) :: {:ok} | Nostrum.Api.error()
Removes another user from a thread, requires that the thread is not archived.
Also requires the MANAGE_THREADS permission, or the creator of the thread if the thread is private.