Table of Contents

Class TextChannel

Namespace
NetCord
Assembly
NetCord.dll

Represents a generic text channel.

public abstract class TextChannel : Channel, IEquatable<Entity>, IJsonModel<JsonChannel>, IInteractionChannel, IEntity, ISpanFormattable, IFormattable
Inheritance
TextChannel
Implements
Derived
Inherited Members

Constructors

TextChannel(JsonChannel, RestClient)

Represents a generic text channel.

protected TextChannel(JsonChannel jsonModel, RestClient client)

Parameters

jsonModel JsonChannel
client RestClient

Properties

LastMessageId

The ID corresponding to the last message sent within the channel. Can be null if the channel is empty.

public ulong? LastMessageId { get; }

Property Value

ulong?

LastPin

The timestamp of the last pinned message, if any, otherwise null.

public DateTimeOffset? LastPin { get; }

Property Value

DateTimeOffset?

Methods

AddMessageReactionAsync(ulong, ReactionEmojiProperties, RestRequestProperties?, CancellationToken)

Adds a reaction to a specific message.

public Task AddMessageReactionAsync(ulong messageId, ReactionEmojiProperties emoji, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

messageId ulong

The ID of the message to react to.

emoji ReactionEmojiProperties

The emoji to use as the reaction.

properties RestRequestProperties

Optional properties to customize the request, can be null.

cancellationToken CancellationToken

A token that can be used to cancel the operation before it completes.

Returns

Task

CreateFromJson(JsonChannel, RestClient)

public static TextChannel CreateFromJson(JsonChannel jsonChannel, RestClient client)

Parameters

jsonChannel JsonChannel
client RestClient

Returns

TextChannel

DeleteAllMessageReactionsAsync(ulong, RestRequestProperties?, CancellationToken)

Removes all reactions from a message.

public Task DeleteAllMessageReactionsAsync(ulong messageId, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

messageId ulong

The ID of the message to clear reactions from.

properties RestRequestProperties

Optional properties to customize the request, can be null.

cancellationToken CancellationToken

A token that can be used to cancel the operation before it completes.

Returns

Task

DeleteAllMessageReactionsForEmojiAsync(ulong, ReactionEmojiProperties, RestRequestProperties?, CancellationToken)

Removes all reactions of a specific emoji from a message.

public Task DeleteAllMessageReactionsForEmojiAsync(ulong messageId, ReactionEmojiProperties emoji, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

messageId ulong

The ID of the message to clear emoji reactions from.

emoji ReactionEmojiProperties

The emoji to remove from all users.

properties RestRequestProperties

Optional properties to customize the request, can be null.

cancellationToken CancellationToken

A token that can be used to cancel the operation before it completes.

Returns

Task

DeleteAsync(RestRequestProperties?, CancellationToken)

Deletes a channel.

public Task<TextChannel> DeleteAsync(RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

properties RestRequestProperties

Optional properties to customize the request, can be null.

cancellationToken CancellationToken

A token that can be used to cancel the operation before it completes.

Returns

Task<TextChannel>

DeleteCurrentUserMessageReactionAsync(ulong, ReactionEmojiProperties, RestRequestProperties?, CancellationToken)

Removes the current user's reaction from a specific message.

public Task DeleteCurrentUserMessageReactionAsync(ulong messageId, ReactionEmojiProperties emoji, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

messageId ulong

The ID of the message to remove the reaction from.

emoji ReactionEmojiProperties

The emoji to remove as a reaction.

properties RestRequestProperties

Optional properties to customize the request, can be null.

cancellationToken CancellationToken

A token that can be used to cancel the operation before it completes.

Returns

Task

DeleteMessageAsync(ulong, RestRequestProperties?, CancellationToken)

Deletes a specific message from a channel.

public Task DeleteMessageAsync(ulong messageId, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

messageId ulong

The ID of the message to delete.

properties RestRequestProperties

Optional properties to customize the request, can be null.

cancellationToken CancellationToken

A token that can be used to cancel the operation before it completes.

Returns

Task

DeleteMessagesAsync(IEnumerable<ulong>, RestRequestProperties?, CancellationToken)

Deletes a set of messages from a channel, in bulk.

public Task DeleteMessagesAsync(IEnumerable<ulong> messageIds, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

messageIds IEnumerable<ulong>

The list of message IDs to delete.

properties RestRequestProperties

Optional properties to customize the request, can be null.

cancellationToken CancellationToken

A token that can be used to cancel the operation before it completes.

Returns

Task

DeleteUserMessageReactionAsync(ulong, ReactionEmojiProperties, ulong, RestRequestProperties?, CancellationToken)

Removes a specific user's reaction from a message.

public Task DeleteUserMessageReactionAsync(ulong messageId, ReactionEmojiProperties emoji, ulong userId, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

messageId ulong

The ID of the message to remove the reaction from.

emoji ReactionEmojiProperties

The emoji to remove as a reaction.

userId ulong

The ID of the user whose reaction will be removed.

properties RestRequestProperties

Optional properties to customize the request, can be null.

cancellationToken CancellationToken

A token that can be used to cancel the operation before it completes.

Returns

Task

EndMessagePollAsync(ulong, RestRequestProperties?, CancellationToken)

public Task<RestMessage> EndMessagePollAsync(ulong messageId, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

messageId ulong
properties RestRequestProperties
cancellationToken CancellationToken

Returns

Task<RestMessage>

EnterTypingScope(TypingScopeProperties?, RestRequestProperties?)

Enters a typing scope for a channel, while waiting for the typing indicator to trigger.

public IDisposable EnterTypingScope(TypingScopeProperties? scopeProperties = null, RestRequestProperties? properties = null)

Parameters

scopeProperties TypingScopeProperties

Optional properties to customize the typing interval, can be null.

properties RestRequestProperties

Optional properties to customize the request, can be null.

Returns

IDisposable

EnterTypingScopeAsync(TypingScopeProperties?, RestRequestProperties?, CancellationToken)

Enters a typing scope for a channel, while waiting for the typing indicator to trigger.

public ValueTask<IDisposable> EnterTypingScopeAsync(TypingScopeProperties? scopeProperties = null, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

scopeProperties TypingScopeProperties

Optional properties to customize the typing interval, can be null.

properties RestRequestProperties

Optional properties to customize the request, can be null.

cancellationToken CancellationToken

A token that can be used to cancel the operation before it completes.

Returns

ValueTask<IDisposable>

GetAsync(RestRequestProperties?, CancellationToken)

Retrieves a channel by its ID.

public Task<TextChannel> GetAsync(RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

properties RestRequestProperties

Optional properties to customize the request, can be null.

cancellationToken CancellationToken

A token that can be used to cancel the operation before it completes.

Returns

Task<TextChannel>

GetMessageAsync(ulong, RestRequestProperties?, CancellationToken)

Retrieves a message from a channel by its ID.

public Task<RestMessage> GetMessageAsync(ulong messageId, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

messageId ulong

The ID of the message to retrieve.

properties RestRequestProperties

Optional properties to customize the request, can be null.

cancellationToken CancellationToken

A token that can be used to cancel the operation before it completes.

Returns

Task<RestMessage>

GetMessagePollAnswerVotersAsync(ulong, int, PaginationProperties<ulong>?, RestRequestProperties?)

public IAsyncEnumerable<User> GetMessagePollAnswerVotersAsync(ulong messageId, int answerId, PaginationProperties<ulong>? paginationProperties = null, RestRequestProperties? properties = null)

Parameters

messageId ulong
answerId int
paginationProperties PaginationProperties<ulong>
properties RestRequestProperties

Returns

IAsyncEnumerable<User>

GetMessageReactionsAsync(ulong, ReactionEmojiProperties, MessageReactionsPaginationProperties?, RestRequestProperties?)

Retrieves a paginated list of users who reacted to a message with a specific emoji.

public IAsyncEnumerable<User> GetMessageReactionsAsync(ulong messageId, ReactionEmojiProperties emoji, MessageReactionsPaginationProperties? paginationProperties = null, RestRequestProperties? properties = null)

Parameters

messageId ulong

The ID of the message to retrieve reactions for.

emoji ReactionEmojiProperties

The emoji to filter reactions by.

paginationProperties MessageReactionsPaginationProperties

Pagination options for fetching users, or null to use defaults.

properties RestRequestProperties

Optional properties to customize each request, can be null.

Returns

IAsyncEnumerable<User>

GetMessagesAroundAsync(ulong, int?, RestRequestProperties?, CancellationToken)

Retrieves a list of messages around a specific message ID within a channel.

public Task<IReadOnlyList<RestMessage>> GetMessagesAroundAsync(ulong messageId, int? limit = null, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

messageId ulong

The ID of the message to center the result around.

limit int?

The maximum number of messages to retrieve, or null to use the default.

properties RestRequestProperties

Optional properties to customize the request, can be null.

cancellationToken CancellationToken

A token that can be used to cancel the operation before it completes.

Returns

Task<IReadOnlyList<RestMessage>>

GetMessagesAsync(PaginationProperties<ulong>?, RestRequestProperties?)

Retrieves an IAsyncEnumerable<T>, representing the messages of a specific channel.

public IAsyncEnumerable<RestMessage> GetMessagesAsync(PaginationProperties<ulong>? paginationProperties = null, RestRequestProperties? properties = null)

Parameters

paginationProperties PaginationProperties<ulong>

Optional properties to customize result pagination, can be null.

properties RestRequestProperties

Optional properties to customize each request, can be null.

Returns

IAsyncEnumerable<RestMessage>

GetPinsAsync(PaginationProperties<DateTimeOffset>?, RestRequestProperties?, CancellationToken)

Retrieves all pinned messages in a channel.

public IAsyncEnumerable<MessagePin> GetPinsAsync(PaginationProperties<DateTimeOffset>? paginationProperties = null, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

paginationProperties PaginationProperties<DateTimeOffset>

Optional properties to customize result pagination, can be null.

properties RestRequestProperties

Optional properties to customize each request, can be null.

cancellationToken CancellationToken

A token that can be used to cancel the operation before it completes.

Returns

IAsyncEnumerable<MessagePin>

Remarks

Requires the ViewChannel permission. If the user is missing the ReadMessageHistory permission in the channel, then no pins will be returned.

ModifyMessageAsync(ulong, Action<MessageOptions>, RestRequestProperties?, CancellationToken)

Modifies the properties of a specific message.

public Task<RestMessage> ModifyMessageAsync(ulong messageId, Action<MessageOptions> action, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

messageId ulong

The ID of the message to modify.

action Action<MessageOptions>

An action that sets the new message properties.

properties RestRequestProperties

Optional properties to customize the request, can be null.

cancellationToken CancellationToken

A token that can be used to cancel the operation before it completes.

Returns

Task<RestMessage>

PinMessageAsync(ulong, RestRequestProperties?, CancellationToken)

Pins a message in a channel.

public Task PinMessageAsync(ulong messageId, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

messageId ulong

The ID of the message to pin.

properties RestRequestProperties

Optional properties to customize the request, can be null.

cancellationToken CancellationToken

A token that can be used to cancel the operation before it completes.

Returns

Task

Remarks

Requires the PinMessages permission. Fires a ChannelPinsUpdate event.

SendMessageAsync(MessageProperties, RestRequestProperties?, CancellationToken)

Sends a new message to the specified text channel.

public Task<RestMessage> SendMessageAsync(MessageProperties message, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

message MessageProperties

The content and properties of the message to send.

properties RestRequestProperties

Optional properties to customize the request, can be null.

cancellationToken CancellationToken

A token that can be used to cancel the operation before it completes.

Returns

Task<RestMessage>

TriggerTypingAsync(RestRequestProperties?, CancellationToken)

Sends a typing indicator to a channel.

public Task TriggerTypingAsync(RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

properties RestRequestProperties

Optional properties to customize the request, can be null.

cancellationToken CancellationToken

A token that can be used to cancel the operation before it completes.

Returns

Task

UnpinMessageAsync(ulong, RestRequestProperties?, CancellationToken)

Unpins a message from a channel.

public Task UnpinMessageAsync(ulong messageId, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

messageId ulong

The ID of the message to unpin.

properties RestRequestProperties

Optional properties to customize the request, can be null.

cancellationToken CancellationToken

A token that can be used to cancel the operation before it completes.

Returns

Task

Remarks

Requires the PinMessages permission. Fires a ChannelPinsUpdate event.