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
jsonModelJsonChannelclientRestClient
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
LastPin
The timestamp of the last pinned message, if any, otherwise null.
public DateTimeOffset? LastPin { get; }
Property Value
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
messageIdulongThe ID of the message to react to.
emojiReactionEmojiPropertiesThe emoji to use as the reaction.
propertiesRestRequestPropertiesOptional properties to customize the request, can be null.
cancellationTokenCancellationTokenA token that can be used to cancel the operation before it completes.
Returns
CreateFromJson(JsonChannel, RestClient)
public static TextChannel CreateFromJson(JsonChannel jsonChannel, RestClient client)
Parameters
jsonChannelJsonChannelclientRestClient
Returns
DeleteAllMessageReactionsAsync(ulong, RestRequestProperties?, CancellationToken)
Removes all reactions from a message.
public Task DeleteAllMessageReactionsAsync(ulong messageId, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
messageIdulongThe ID of the message to clear reactions from.
propertiesRestRequestPropertiesOptional properties to customize the request, can be null.
cancellationTokenCancellationTokenA token that can be used to cancel the operation before it completes.
Returns
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
messageIdulongThe ID of the message to clear emoji reactions from.
emojiReactionEmojiPropertiesThe emoji to remove from all users.
propertiesRestRequestPropertiesOptional properties to customize the request, can be null.
cancellationTokenCancellationTokenA token that can be used to cancel the operation before it completes.
Returns
DeleteAsync(RestRequestProperties?, CancellationToken)
Deletes a channel.
public Task<TextChannel> DeleteAsync(RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
propertiesRestRequestPropertiesOptional properties to customize the request, can be null.
cancellationTokenCancellationTokenA token that can be used to cancel the operation before it completes.
Returns
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
messageIdulongThe ID of the message to remove the reaction from.
emojiReactionEmojiPropertiesThe emoji to remove as a reaction.
propertiesRestRequestPropertiesOptional properties to customize the request, can be null.
cancellationTokenCancellationTokenA token that can be used to cancel the operation before it completes.
Returns
DeleteMessageAsync(ulong, RestRequestProperties?, CancellationToken)
Deletes a specific message from a channel.
public Task DeleteMessageAsync(ulong messageId, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
messageIdulongThe ID of the message to delete.
propertiesRestRequestPropertiesOptional properties to customize the request, can be null.
cancellationTokenCancellationTokenA token that can be used to cancel the operation before it completes.
Returns
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
messageIdsIEnumerable<ulong>The list of message IDs to delete.
propertiesRestRequestPropertiesOptional properties to customize the request, can be null.
cancellationTokenCancellationTokenA token that can be used to cancel the operation before it completes.
Returns
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
messageIdulongThe ID of the message to remove the reaction from.
emojiReactionEmojiPropertiesThe emoji to remove as a reaction.
userIdulongThe ID of the user whose reaction will be removed.
propertiesRestRequestPropertiesOptional properties to customize the request, can be null.
cancellationTokenCancellationTokenA token that can be used to cancel the operation before it completes.
Returns
EndMessagePollAsync(ulong, RestRequestProperties?, CancellationToken)
public Task<RestMessage> EndMessagePollAsync(ulong messageId, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
messageIdulongpropertiesRestRequestPropertiescancellationTokenCancellationToken
Returns
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
scopePropertiesTypingScopePropertiesOptional properties to customize the typing interval, can be null.
propertiesRestRequestPropertiesOptional properties to customize the request, can be null.
Returns
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
scopePropertiesTypingScopePropertiesOptional properties to customize the typing interval, can be null.
propertiesRestRequestPropertiesOptional properties to customize the request, can be null.
cancellationTokenCancellationTokenA token that can be used to cancel the operation before it completes.
Returns
GetAsync(RestRequestProperties?, CancellationToken)
Retrieves a channel by its ID.
public Task<TextChannel> GetAsync(RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
propertiesRestRequestPropertiesOptional properties to customize the request, can be null.
cancellationTokenCancellationTokenA token that can be used to cancel the operation before it completes.
Returns
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
messageIdulongThe ID of the message to retrieve.
propertiesRestRequestPropertiesOptional properties to customize the request, can be null.
cancellationTokenCancellationTokenA token that can be used to cancel the operation before it completes.
Returns
GetMessagePollAnswerVotersAsync(ulong, int, PaginationProperties<ulong>?, RestRequestProperties?)
public IAsyncEnumerable<User> GetMessagePollAnswerVotersAsync(ulong messageId, int answerId, PaginationProperties<ulong>? paginationProperties = null, RestRequestProperties? properties = null)
Parameters
messageIdulonganswerIdintpaginationPropertiesPaginationProperties<ulong>propertiesRestRequestProperties
Returns
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
messageIdulongThe ID of the message to retrieve reactions for.
emojiReactionEmojiPropertiesThe emoji to filter reactions by.
paginationPropertiesMessageReactionsPaginationPropertiesPagination options for fetching users, or null to use defaults.
propertiesRestRequestPropertiesOptional properties to customize each request, can be null.
Returns
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
messageIdulongThe ID of the message to center the result around.
limitint?The maximum number of messages to retrieve, or null to use the default.
propertiesRestRequestPropertiesOptional properties to customize the request, can be null.
cancellationTokenCancellationTokenA token that can be used to cancel the operation before it completes.
Returns
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
paginationPropertiesPaginationProperties<ulong>Optional properties to customize result pagination, can be null.
propertiesRestRequestPropertiesOptional properties to customize each request, can be null.
Returns
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
paginationPropertiesPaginationProperties<DateTimeOffset>Optional properties to customize result pagination, can be null.
propertiesRestRequestPropertiesOptional properties to customize each request, can be null.
cancellationTokenCancellationTokenA token that can be used to cancel the operation before it completes.
Returns
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
messageIdulongThe ID of the message to modify.
actionAction<MessageOptions>An action that sets the new message properties.
propertiesRestRequestPropertiesOptional properties to customize the request, can be null.
cancellationTokenCancellationTokenA token that can be used to cancel the operation before it completes.
Returns
PinMessageAsync(ulong, RestRequestProperties?, CancellationToken)
Pins a message in a channel.
public Task PinMessageAsync(ulong messageId, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
messageIdulongThe ID of the message to pin.
propertiesRestRequestPropertiesOptional properties to customize the request, can be null.
cancellationTokenCancellationTokenA token that can be used to cancel the operation before it completes.
Returns
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
messageMessagePropertiesThe content and properties of the message to send.
propertiesRestRequestPropertiesOptional properties to customize the request, can be null.
cancellationTokenCancellationTokenA token that can be used to cancel the operation before it completes.
Returns
TriggerTypingAsync(RestRequestProperties?, CancellationToken)
Sends a typing indicator to a channel.
public Task TriggerTypingAsync(RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
propertiesRestRequestPropertiesOptional properties to customize the request, can be null.
cancellationTokenCancellationTokenA token that can be used to cancel the operation before it completes.
Returns
UnpinMessageAsync(ulong, RestRequestProperties?, CancellationToken)
Unpins a message from a channel.
public Task UnpinMessageAsync(ulong messageId, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
messageIdulongThe ID of the message to unpin.
propertiesRestRequestPropertiesOptional properties to customize the request, can be null.
cancellationTokenCancellationTokenA token that can be used to cancel the operation before it completes.
Returns
Remarks
Requires the PinMessages permission. Fires a ChannelPinsUpdate event.