Table of Contents

Class RestThreadChannel

Namespace
Discord.Rest
Assembly
Discord.Net.Rest.dll

Represents a thread channel received over REST.

public class RestThreadChannel : RestTextChannel, IUpdateable, IRestMessageChannel, IThreadChannel, ITextChannel, IMessageChannel, IMentionable, INestedChannel, IIntegrationChannel, IGuildChannel, IChannel, ISnowflakeEntity, IEntity<ulong>, IDeletable
Inheritance
RestThreadChannel
Implements
Inherited Members
Extension Methods

Properties

AppliedTags

Gets ids of tags applied to a forum thread

public IReadOnlyCollection<ulong> AppliedTags { get; }

Property Value

IReadOnlyCollection<ulong>

Remarks

This property is only available on forum threads.

ArchiveTimestamp

Gets the timestamp when the thread's archive status was last changed, used for calculating recent activity.

public DateTimeOffset ArchiveTimestamp { get; }

Property Value

DateTimeOffset

AutoArchiveDuration

Gets the duration of time before the thread is automatically archived after no activity.

public ThreadArchiveDuration AutoArchiveDuration { get; }

Property Value

ThreadArchiveDuration

CreatedAt

Gets when the thread was created.

public override DateTimeOffset CreatedAt { get; }

Property Value

DateTimeOffset

Remarks

This property is only populated for threads created after 2022-01-09, hence the default date of this property will be that date.

HasJoined

Gets whether or not the current user has joined this thread.

public bool HasJoined { get; }

Property Value

bool

IsArchived

Gets whether or not the current thread is archived.

public bool IsArchived { get; }

Property Value

bool

IsInvitable

Gets whether non-moderators can add other non-moderators to a thread.

public bool? IsInvitable { get; }

Property Value

bool?

Remarks

This property is only available on private threads.

IsLocked

Gets whether or not the current thread is locked.

public bool IsLocked { get; }

Property Value

bool

MemberCount

Gets an approximate count of users in a thread, stops counting after 50.

public int MemberCount { get; }

Property Value

int

MessageCount

Gets an approximate count of messages in a thread, stops counting after 50.

public int MessageCount { get; }

Property Value

int

OwnerId

Gets the id of the creator of the thread.

public ulong OwnerId { get; }

Property Value

ulong

ParentChannelId

Gets the parent text channel id.

public ulong ParentChannelId { get; }

Property Value

ulong

PermissionOverwrites

Gets a collection of permission overwrites for this channel.

public override IReadOnlyCollection<Overwrite> PermissionOverwrites { get; }

Property Value

IReadOnlyCollection<Overwrite>

A collection of overwrites associated with this channel.

Remarks

This method is not supported in threads.

Type

Gets the type of the current thread channel.

public ThreadType Type { get; }

Property Value

ThreadType

Methods

AddPermissionOverwriteAsync(IRole, OverwritePermissions, RequestOptions)

Adds or updates the permission overwrite for the given role.

public override Task AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions, RequestOptions options = null)

Parameters

role IRole

The role to add the overwrite to.

permissions OverwritePermissions

The overwrite to add to the role.

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task representing the asynchronous permission operation for adding the specified permissions to the channel.

Remarks

This method is not supported in threads.

AddPermissionOverwriteAsync(IUser, OverwritePermissions, RequestOptions)

Adds or updates the permission overwrite for the given user.

public override Task AddPermissionOverwriteAsync(IUser user, OverwritePermissions permissions, RequestOptions options = null)

Parameters

user IUser

The user to add the overwrite to.

permissions OverwritePermissions

The overwrite to add to the user.

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task representing the asynchronous permission operation for adding the specified permissions to the channel.

Remarks

This method is not supported in threads.

AddUserAsync(IGuildUser, RequestOptions)

Adds a user to this thread.

public Task AddUserAsync(IGuildUser user, RequestOptions options = null)

Parameters

user IGuildUser

The IGuildUser to add.

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task that represents the asynchronous operation of adding a member to a thread.

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

Creates a new invite to this channel.

public override 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);

Remarks

This method is not supported in threads.

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

Creates a new invite to this channel.

public override Task<IInviteMetadata> CreateInviteToApplicationAsync(ulong applicationId, int? maxAge, 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.

Remarks

This method is not supported in threads.

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

Creates a new invite to this channel.

public override 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);

Remarks

This method is not supported in threads.

CreateWebhookAsync(string, Stream, RequestOptions)

Creates a webhook in this text channel.

public override 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.

Remarks

This method is not supported in threads.

GetActiveThreadsAsync(RequestOptions)

Gets a collection of active threads within this channel.

public override 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.

Exceptions

NotSupportedException

This method is not supported in threads.

GetCategoryAsync(RequestOptions)

Gets the parent (category) channel of this channel.

public override Task<ICategoryChannel> GetCategoryAsync(RequestOptions options = null)

Parameters

options RequestOptions

The options to be used when sending the request.

Returns

Task<ICategoryChannel>

A task that represents the asynchronous get operation. The task result contains the category channel representing the parent of this channel; null if none is set.

Remarks

This method is not supported in threads.

GetInvitesAsync(RequestOptions)

Gets a collection of all invites to this channel.

public override 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();

Remarks

This method is not supported in threads.

GetPermissionOverwrite(IRole)

Gets the permission overwrite for a specific role.

public override OverwritePermissions? GetPermissionOverwrite(IRole role)

Parameters

role IRole

The role to get the overwrite from.

Returns

OverwritePermissions?

An overwrite object for the targeted role; null if none is set.

Remarks

This method is not supported in threads.

GetPermissionOverwrite(IUser)

Gets the permission overwrite for a specific user.

public override OverwritePermissions? GetPermissionOverwrite(IUser user)

Parameters

user IUser

The user to get the overwrite from.

Returns

OverwritePermissions?

An overwrite object for the targeted user; null if none is set.

Remarks

This method is not supported in threads.

GetThreadUsersAsync(int, RequestOptions)

Gets a collection of users within this thread.

public IAsyncEnumerable<IReadOnlyCollection<RestThreadUser>> GetThreadUsersAsync(int limit = 100, RequestOptions options = null)

Parameters

limit int

Sets the limit of the user count for each request. 100 by default.

options RequestOptions

Returns

IAsyncEnumerable<IReadOnlyCollection<RestThreadUser>>

A task that represents the asynchronous get operation. The task result contains a collection of thread users found within this thread channel.

GetUserAsync(ulong, RequestOptions)

Gets a user within this thread.

public Task<RestThreadUser> GetUserAsync(ulong userId, RequestOptions options = null)

Parameters

userId ulong

The id of the user to fetch.

options RequestOptions

The options to be used when sending the request.

Returns

Task<RestThreadUser>

A task representing the asynchronous get operation. The task returns a RestThreadUser if found, otherwise null.

GetUsersAsync(RequestOptions)

Gets a collection of users within this thread.

[Obsolete("Please use GetThreadUsersAsync instead of this. Will be removed in next major version.", false)]
public Task<IReadOnlyCollection<RestThreadUser>> GetUsersAsync(RequestOptions options = null)

Parameters

options RequestOptions

The options to be used when sending the request.

Returns

Task<IReadOnlyCollection<RestThreadUser>>

A task representing the asynchronous get operation. The task returns a IReadOnlyCollection<T> of RestThreadUser's.

GetWebhookAsync(ulong, RequestOptions)

Gets a webhook available in this text channel.

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

Parameters

id ulong

The identifier of the webhook.

options RequestOptions

The options to be used when sending the request.

Returns

Task<RestWebhook>

A task that represents the asynchronous get operation. The task result contains a webhook associated with the identifier; null if the webhook is not found.

Remarks

This method is not supported in threads.

GetWebhooksAsync(RequestOptions)

Gets the webhooks available in this text channel.

public override 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 get operation. The task result contains a read-only collection of webhooks that is available in this channel.

Remarks

This method is not supported in threads.

JoinAsync(RequestOptions)

Joins the current thread.

public Task JoinAsync(RequestOptions options = null)

Parameters

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task that represents the asynchronous join operation.

LeaveAsync(RequestOptions)

Leaves the current thread.

public Task LeaveAsync(RequestOptions options = null)

Parameters

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task that represents the asynchronous leave operation.

ModifyAsync(Action<TextChannelProperties>, RequestOptions)

Modifies this text channel.

public override Task ModifyAsync(Action<TextChannelProperties> func, RequestOptions options = null)

Parameters

func Action<TextChannelProperties>

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.

See Also

ModifyAsync(Action<ThreadChannelProperties>, RequestOptions)

Modifies this thread channel.

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

Parameters

func Action<ThreadChannelProperties>

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.

See Also

RemovePermissionOverwriteAsync(IRole, RequestOptions)

Removes the permission overwrite for the given role, if one exists.

public override Task RemovePermissionOverwriteAsync(IRole role, RequestOptions options = null)

Parameters

role IRole

The role to remove the overwrite from.

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task representing the asynchronous operation for removing the specified permissions from the channel.

Remarks

This method is not supported in threads.

RemovePermissionOverwriteAsync(IUser, RequestOptions)

Removes the permission overwrite for the given user, if one exists.

public override Task RemovePermissionOverwriteAsync(IUser user, RequestOptions options = null)

Parameters

user IUser

The user to remove the overwrite from.

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task representing the asynchronous operation for removing the specified permissions from the channel.

Remarks

This method is not supported in threads.

RemoveUserAsync(IGuildUser, RequestOptions)

Removes a user from this thread.

public Task RemoveUserAsync(IGuildUser user, RequestOptions options = null)

Parameters

user IGuildUser

The IGuildUser to remove from this thread.

options RequestOptions

The options to be used when sending the request.

Returns

Task

A task that represents the asynchronous operation of removing a user from this thread.