Table of Contents

Class SocketForumChannel

Namespace
Discord.WebSocket
Assembly
Discord.Net.WebSocket.dll

Represents a forum channel in a guild.

public class SocketForumChannel : SocketGuildChannel, IForumChannel, IMentionable, INestedChannel, IIntegrationChannel, IGuildChannel, IChannel, ISnowflakeEntity, IEntity<ulong>, IDeletable
Inheritance
SocketForumChannel
Implements
Derived
Inherited Members
Extension Methods

Properties

Category

Gets the parent (category) of this channel in the guild's channel list.

public ICategoryChannel Category { get; }

Property Value

ICategoryChannel

An ICategoryChannel representing the parent of this channel; null if none is set.

CategoryId

Gets the parent (category) ID of this channel in the guild's channel list.

public ulong? CategoryId { get; }

Property Value

ulong?

A ulong representing the snowflake identifier of the parent of this channel; null if none is set.

DefaultAutoArchiveDuration

Gets the default archive duration for a newly created post.

public ThreadArchiveDuration DefaultAutoArchiveDuration { get; }

Property Value

ThreadArchiveDuration

DefaultLayout

Gets the rule used to display posts in a forum channel.

public ForumLayout DefaultLayout { get; }

Property Value

ForumLayout

DefaultReactionEmoji

Gets the emoji to show in the add reaction button on a thread in a forum channel

public IEmote DefaultReactionEmoji { get; }

Property Value

IEmote

Remarks

If the emoji is Emote only the Id will be populated. Use GetEmoteAsync(ulong, RequestOptions) to get the emoji.

DefaultSlowModeInterval

Gets the current default slow-mode delay for threads in this forum channel.

public int DefaultSlowModeInterval { get; }

Property Value

int

An int representing the time in seconds required before the user can send another message; 0 if disabled.

DefaultSortOrder

Gets the rule used to order posts in forum channels.

public ForumSortOrder? DefaultSortOrder { get; }

Property Value

ForumSortOrder?

Remarks

Defaults to null, which indicates a preferred sort order hasn't been set

IsNsfw

Gets a value that indicates whether the channel is NSFW.

public bool IsNsfw { get; }

Property Value

bool

true if the channel has the NSFW flag enabled; otherwise false.

Mention

Returns a special string used to mention this object.

public string Mention { get; }

Property Value

string

A string that is recognized by Discord as a mention (e.g. <@168693960628371456>).

Tags

Gets a collection of tags inside of this forum channel.

public IReadOnlyCollection<ForumTag> Tags { get; }

Property Value

IReadOnlyCollection<ForumTag>

ThreadCreationInterval

Gets the current rate limit on creating posts in this forum channel.

public int ThreadCreationInterval { get; }

Property Value

int

An int representing the time in seconds required before the user can send another message; 0 if disabled.

Topic

Gets the current topic for this text channel.

public string Topic { get; }

Property Value

string

A string representing the topic set in the channel; null if none is set.

Methods

CreateInviteAsync(int?, int?, bool, bool, RequestOptions)

Creates a new invite to this channel.

public virtual Task<IInviteMetadata> CreateInviteAsync(int? maxAge = 86400, int? maxUses = null, bool isTemporary = false, bool isUnique = false, RequestOptions options = null)

Parameters

maxAge int?

The time (in seconds) until the invite expires. Set to null to never expire.

maxUses int?

The max amount of times this invite may be used. Set to null to have unlimited uses.

isTemporary bool

If true, the user accepting this invite will be kicked from the guild after closing their client.

isUnique bool

If true, don't try to reuse a similar invite (useful for creating many unique one time use invites).

options RequestOptions

The options to be used when sending the request.

Returns

Task<IInviteMetadata>

A task that represents the asynchronous invite creation operation. The task result contains an invite metadata object containing information for the created invite.

Examples

The following example creates a new invite to this channel; the invite lasts for 12 hours and can only be used 3 times throughout its lifespan.

  await guildChannel.CreateInviteAsync(maxAge: 43200, maxUses: 3);

CreateInviteToApplicationAsync(DefaultApplications, int?, int?, bool, bool, RequestOptions)

Creates a new invite to this channel.

public virtual Task<IInviteMetadata> CreateInviteToApplicationAsync(DefaultApplications application, int? maxAge = 86400, int? maxUses = null, bool isTemporary = false, bool isUnique = false, RequestOptions options = null)

Parameters

application DefaultApplications

The application to open for this invite.

maxAge int?

The time (in seconds) until the invite expires. Set to null to never expire.

maxUses int?

The max amount of times this invite may be used. Set to null to have unlimited uses.

isTemporary bool

If true, the user accepting this invite will be kicked from the guild after closing their client.

isUnique bool

If true, don't try to reuse a similar invite (useful for creating many unique one time use invites).

options RequestOptions

The options to be used when sending the request.

Returns

Task<IInviteMetadata>

A task that represents the asynchronous invite creation operation. The task result contains an invite metadata object containing information for the created invite.

CreateInviteToApplicationAsync(ulong, int?, int?, bool, bool, RequestOptions)

Creates a new invite to this channel.

public virtual Task<IInviteMetadata> CreateInviteToApplicationAsync(ulong applicationId, int? maxAge = 86400, int? maxUses = null, bool isTemporary = false, bool isUnique = false, RequestOptions options = null)

Parameters

applicationId ulong

The id of the embedded application to open for this invite.

maxAge int?

The time (in seconds) until the invite expires. Set to null to never expire.

maxUses int?

The max amount of times this invite may be used. Set to null to have unlimited uses.

isTemporary bool

If true, the user accepting this invite will be kicked from the guild after closing their client.

isUnique bool

If true, don't try to reuse a similar invite (useful for creating many unique one time use invites).

options RequestOptions

The options to be used when sending the request.

Returns

Task<IInviteMetadata>

A task that represents the asynchronous invite creation operation. The task result contains an invite metadata object containing information for the created invite.

CreateInviteToStreamAsync(IUser, int?, int?, bool, bool, RequestOptions)

Creates a new invite to this channel.

public virtual Task<IInviteMetadata> CreateInviteToStreamAsync(IUser user, int? maxAge, int? maxUses = null, bool isTemporary = false, bool isUnique = false, RequestOptions options = null)

Parameters

user IUser

The id of the user whose stream to display for this invite.

maxAge int?

The time (in seconds) until the invite expires. Set to null to never expire.

maxUses int?

The max amount of times this invite may be used. Set to null to have unlimited uses.

isTemporary bool

If true, the user accepting this invite will be kicked from the guild after closing their client.

isUnique bool

If true, don't try to reuse a similar invite (useful for creating many unique one time use invites).

options RequestOptions

The options to be used when sending the request.

Returns

Task<IInviteMetadata>

A task that represents the asynchronous invite creation operation. The task result contains an invite metadata object containing information for the created invite.

Examples

The following example creates a new invite to this channel; the invite lasts for 12 hours and can only be used 3 times throughout its lifespan.

  await guildChannel.CreateInviteAsync(maxAge: 43200, maxUses: 3);

CreatePostAsync(string, ThreadArchiveDuration, int?, string, Embed, RequestOptions, AllowedMentions, MessageComponent, ISticker[], Embed[], MessageFlags, ForumTag[])

Creates a new post (thread) within the forum.

public Task<RestThreadChannel> CreatePostAsync(string title, ThreadArchiveDuration archiveDuration = ThreadArchiveDuration.OneDay, int? slowmode = null, string text = null, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None, ForumTag[] tags = null)

Parameters

title string

The title of the post.

archiveDuration ThreadArchiveDuration

The archive duration of the post.

slowmode int?

The slowmode for the posts thread.

text string

The message to be sent.

embed Embed

The RichEmbed to be sent.

options RequestOptions

The options to be used when sending the request.

allowedMentions AllowedMentions

Specifies if notifications are sent for mentioned users and roles in the message text. If null, all mentioned roles and users will be notified.

components MessageComponent

The message components to be included with this message. Used for interactions.

stickers ISticker[]

A collection of stickers to send with the message.

embeds Embed[]

A array of Embeds to send with this response. Max 10.

flags MessageFlags

A message flag to be applied to the sent message, only SuppressEmbeds is permitted.

tags ForumTag[]

An array of ForumTag to be applied to the post.

Returns

Task<RestThreadChannel>

A task that represents the asynchronous creation operation.

CreatePostWithFileAsync(string, FileAttachment, ThreadArchiveDuration, int?, string, Embed, RequestOptions, AllowedMentions, MessageComponent, ISticker[], Embed[], MessageFlags, ForumTag[])

Creates a new post (thread) within the forum.

public Task<RestThreadChannel> CreatePostWithFileAsync(string title, FileAttachment attachment, ThreadArchiveDuration archiveDuration = ThreadArchiveDuration.OneDay, int? slowmode = null, string text = null, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None, ForumTag[] tags = null)

Parameters

title string

The title of the post.

attachment FileAttachment

The attachment containing the file and description.

archiveDuration ThreadArchiveDuration

The archive duration of the post.

slowmode int?

The slowmode for the posts thread.

text string

The message to be sent.

embed Embed

The RichEmbed to be sent.

options RequestOptions

The options to be used when sending the request.

allowedMentions AllowedMentions

Specifies if notifications are sent for mentioned users and roles in the message text. If null, all mentioned roles and users will be notified.

components MessageComponent

The message components to be included with this message. Used for interactions.

stickers ISticker[]

A collection of stickers to send with the file.

embeds Embed[]

A array of Embeds to send with this response. Max 10.

flags MessageFlags

A message flag to be applied to the sent message, only SuppressEmbeds is permitted.

tags ForumTag[]

An array of ForumTag to be applied to the post.

Returns

Task<RestThreadChannel>

A task that represents the asynchronous creation operation.

CreatePostWithFileAsync(string, Stream, string, ThreadArchiveDuration, int?, string, Embed, RequestOptions, bool, AllowedMentions, MessageComponent, ISticker[], Embed[], MessageFlags, ForumTag[])

Creates a new post (thread) within the forum.

public Task<RestThreadChannel> CreatePostWithFileAsync(string title, Stream stream, string filename, ThreadArchiveDuration archiveDuration = ThreadArchiveDuration.OneDay, int? slowmode = null, string text = null, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None, ForumTag[] tags = null)

Parameters

title string

The title of the post.

stream Stream

The Stream of the file to be sent.

filename string

The name of the attachment.

archiveDuration ThreadArchiveDuration

The archive duration of the post.

slowmode int?

The slowmode for the posts thread.

text string

The message to be sent.

embed Embed

The RichEmbed to be sent.

options RequestOptions

The options to be used when sending the request.

isSpoiler bool

Whether the message attachment should be hidden as a spoiler.

allowedMentions AllowedMentions

Specifies if notifications are sent for mentioned users and roles in the message text. If null, all mentioned roles and users will be notified.

components MessageComponent

The message components to be included with this message. Used for interactions.

stickers ISticker[]

A collection of stickers to send with the file.

embeds Embed[]

A array of Embeds to send with this response. Max 10.

flags MessageFlags

A message flag to be applied to the sent message, only SuppressEmbeds is permitted.

tags ForumTag[]

An array of ForumTag to be applied to the post.

Returns

Task<RestThreadChannel>

A task that represents the asynchronous creation operation.

CreatePostWithFileAsync(string, string, ThreadArchiveDuration, int?, string, Embed, RequestOptions, bool, AllowedMentions, MessageComponent, ISticker[], Embed[], MessageFlags, ForumTag[])

Creates a new post (thread) within the forum.

public Task<RestThreadChannel> CreatePostWithFileAsync(string title, string filePath, ThreadArchiveDuration archiveDuration = ThreadArchiveDuration.OneDay, int? slowmode = null, string text = null, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None, ForumTag[] tags = null)

Parameters

title string

The title of the post.

filePath string

The file path of the file.

archiveDuration ThreadArchiveDuration

The archive duration of the post.

slowmode int?

The slowmode for the posts thread.

text string

The message to be sent.

embed Embed

The RichEmbed to be sent.

options RequestOptions

The options to be used when sending the request.

isSpoiler bool

Whether the message attachment should be hidden as a spoiler.

allowedMentions AllowedMentions

Specifies if notifications are sent for mentioned users and roles in the message text. If null, all mentioned roles and users will be notified.

components MessageComponent

The message components to be included with this message. Used for interactions.

stickers ISticker[]

A collection of stickers to send with the file.

embeds Embed[]

A array of Embeds to send with this response. Max 10.

flags MessageFlags

A message flag to be applied to the sent message, only SuppressEmbeds is permitted.

tags ForumTag[]

An array of ForumTag to be applied to the post.

Returns

Task<RestThreadChannel>

A task that represents the asynchronous creation operation.

CreatePostWithFilesAsync(string, IEnumerable<FileAttachment>, ThreadArchiveDuration, int?, string, Embed, RequestOptions, AllowedMentions, MessageComponent, ISticker[], Embed[], MessageFlags, ForumTag[])

Creates a new post (thread) within the forum.

public Task<RestThreadChannel> CreatePostWithFilesAsync(string title, IEnumerable<FileAttachment> attachments, ThreadArchiveDuration archiveDuration = ThreadArchiveDuration.OneDay, int? slowmode = null, string text = null, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None, ForumTag[] tags = null)

Parameters

title string

The title of the post.

attachments IEnumerable<FileAttachment>

A collection of attachments to upload.

archiveDuration ThreadArchiveDuration

The archive duration of the post.

slowmode int?

The slowmode for the posts thread.

text string

The message to be sent.

embed Embed

The RichEmbed to be sent.

options RequestOptions

The options to be used when sending the request.

allowedMentions AllowedMentions

Specifies if notifications are sent for mentioned users and roles in the message text. If null, all mentioned roles and users will be notified.

components MessageComponent

The message components to be included with this message. Used for interactions.

stickers ISticker[]

A collection of stickers to send with the file.

embeds Embed[]

An array of Embeds to send with this response. Max 10.

flags MessageFlags

A message flag to be applied to the sent message, only SuppressEmbeds is permitted.

tags ForumTag[]

An array of ForumTag to be applied to the post.

Returns

Task<RestThreadChannel>

A task that represents the asynchronous creation operation.

CreateWebhookAsync(string, Stream, RequestOptions)

Creates a webhook in this channel.

public Task<RestWebhook> CreateWebhookAsync(string name, Stream avatar = null, RequestOptions options = null)

Parameters

name string

The name of the webhook.

avatar Stream

The avatar of the webhook.

options RequestOptions

The options to be used when sending the request.

Returns

Task<RestWebhook>

A task that represents the asynchronous creation operation. The task result contains the newly created webhook.

GetActiveThreadsAsync(RequestOptions)

Gets a collection of active threads within this channel.

public Task<IReadOnlyCollection<RestThreadChannel>> GetActiveThreadsAsync(RequestOptions options = null)

Parameters

options RequestOptions

The options to be used when sending the request.

Returns

Task<IReadOnlyCollection<RestThreadChannel>>

A task that represents an asynchronous get operation for retrieving the threads. The task result contains a collection of active threads.

GetInvitesAsync(RequestOptions)

Gets a collection of all invites to this channel.

public virtual Task<IReadOnlyCollection<IInviteMetadata>> GetInvitesAsync(RequestOptions options = null)

Parameters

options RequestOptions

The options to be used when sending the request.

Returns

Task<IReadOnlyCollection<IInviteMetadata>>

A task that represents the asynchronous get operation. The task result contains a read-only collection of invite metadata that are created for this channel.

Examples

The following example gets all of the invites that have been created in this channel and selects the most used invite.

  var invites = await channel.GetInvitesAsync();
                             if (invites.Count == 0) return;
                             var invite = invites.OrderByDescending(x => x.Uses).FirstOrDefault();

GetJoinedPrivateArchivedThreadsAsync(int?, DateTimeOffset?, RequestOptions)

Gets a collection of privately archived threads that the current bot has joined within this forum channel.

public Task<IReadOnlyCollection<RestThreadChannel>> GetJoinedPrivateArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null)

Parameters

limit int?

The optional limit of how many to get.

before DateTimeOffset?

The optional date to return threads created before this timestamp.

options RequestOptions

The options to be used when sending the request.

Returns

Task<IReadOnlyCollection<RestThreadChannel>>

A task that represents an asynchronous get operation for retrieving the threads. The task result contains a collection of privately archived threads.

GetPrivateArchivedThreadsAsync(int?, DateTimeOffset?, RequestOptions)

Gets a collection of privately archived threads within this forum channel.

public Task<IReadOnlyCollection<RestThreadChannel>> GetPrivateArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null)

Parameters

limit int?

The optional limit of how many to get.

before DateTimeOffset?

The optional date to return threads created before this timestamp.

options RequestOptions

The options to be used when sending the request.

Returns

Task<IReadOnlyCollection<RestThreadChannel>>

A task that represents an asynchronous get operation for retrieving the threads. The task result contains a collection of privately archived threads.

Remarks

The bot requires the ManageThreads permission in order to execute this request.

GetPublicArchivedThreadsAsync(int?, DateTimeOffset?, RequestOptions)

Gets a collection of publicly archived threads within this forum channel.

public Task<IReadOnlyCollection<RestThreadChannel>> GetPublicArchivedThreadsAsync(int? limit = null, DateTimeOffset? before = null, RequestOptions options = null)

Parameters

limit int?

The optional limit of how many to get.

before DateTimeOffset?

The optional date to return threads created before this timestamp.

options RequestOptions

The options to be used when sending the request.

Returns

Task<IReadOnlyCollection<RestThreadChannel>>

A task that represents an asynchronous get operation for retrieving the threads. The task result contains a collection of publicly archived threads.

GetWebhookAsync(ulong, RequestOptions)

Creates a webhook in this channel.

public Task<RestWebhook> GetWebhookAsync(ulong id, RequestOptions options = null)

Parameters

id ulong
options RequestOptions

The options to be used when sending the request.

Returns

Task<RestWebhook>

A task that represents the asynchronous creation operation. The task result contains the newly created webhook.

GetWebhooksAsync(RequestOptions)

Creates a webhook in this channel.

public Task<IReadOnlyCollection<RestWebhook>> GetWebhooksAsync(RequestOptions options = null)

Parameters

options RequestOptions

The options to be used when sending the request.

Returns

Task<IReadOnlyCollection<RestWebhook>>

A task that represents the asynchronous creation operation. The task result contains the newly created webhook.

ModifyAsync(Action<ForumChannelProperties>, RequestOptions)

Modifies this forum channel.

public virtual Task ModifyAsync(Action<ForumChannelProperties> func, RequestOptions options = null)

Parameters

func Action<ForumChannelProperties>

The delegate containing the properties to modify the channel with.

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task that represents the asynchronous modification operation.

Remarks

This method modifies the current forum channel with the specified properties. To see an example of this method and what properties are available, please refer to ForumChannelProperties.

SyncPermissionsAsync(RequestOptions)

Syncs the permissions of this nested channel with its parent's.

public virtual Task SyncPermissionsAsync(RequestOptions options = null)

Parameters

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task that represents the asynchronous operation for syncing channel permissions with its parent's.