Class SocketTextChannel
Represents a WebSocket-based channel in a guild that can send and receive messages.
Inheritance
Implements
Inherited Members
Namespace: Discord.WebSocket
Assembly: Discord.Net.WebSocket.dll
Syntax
public class SocketTextChannel : SocketGuildChannel, IEntity<ulong>, ITextChannel, IMentionable, INestedChannel, IIntegrationChannel, IGuildChannel, IDeletable, ISocketMessageChannel, IMessageChannel, IChannel, ISnowflakeEntity, IEntity<ulong>
Properties
| Improve this Doc View SourceCachedMessages
Gets all messages in this channel's cache.
Declaration
public IReadOnlyCollection<SocketMessage> CachedMessages { get; }
Property Value
Type | Description |
---|---|
IReadOnlyCollection<SocketMessage> | A read-only collection of WebSocket-based messages. |
Category
Gets the parent (category) of this channel in the guild's channel list.
Declaration
public ICategoryChannel Category { get; }
Property Value
Type | Description |
---|---|
ICategoryChannel | An ICategoryChannel representing the parent of this channel; null if none is set. |
CategoryId
Declaration
public ulong? CategoryId { get; }
Property Value
Type | Description |
---|---|
Nullable<UInt64> |
DefaultArchiveDuration
Gets the default auto-archive duration for client-created threads in this channel.
Declaration
public ThreadArchiveDuration DefaultArchiveDuration { get; }
Property Value
Type | Description |
---|---|
ThreadArchiveDuration | The default auto-archive duration for thread creation in this channel. |
Remarks
The value of this property does not affect API thread creation, it will not respect this value.
DefaultSlowModeInterval
Declaration
public int DefaultSlowModeInterval { get; }
Property Value
Type | Description |
---|---|
Int32 |
IsNsfw
Declaration
public bool IsNsfw { get; }
Property Value
Type | Description |
---|---|
Boolean |
Mention
Declaration
public string Mention { get; }
Property Value
Type | Description |
---|---|
String |
SlowModeInterval
Declaration
public virtual int SlowModeInterval { get; }
Property Value
Type | Description |
---|---|
Int32 |
Threads
Gets a collection of threads within this text channel.
Declaration
public IReadOnlyCollection<SocketThreadChannel> Threads { get; }
Property Value
Type | Description |
---|---|
IReadOnlyCollection<SocketThreadChannel> |
Topic
Declaration
public string Topic { get; }
Property Value
Type | Description |
---|---|
String |
Users
Gets a collection of users that are able to view the channel.
Declaration
public override IReadOnlyCollection<SocketGuildUser> Users { get; }
Property Value
Type | Description |
---|---|
IReadOnlyCollection<SocketGuildUser> | A read-only collection of users that can access the channel (i.e. the users seen in the user list). |
Overrides
Remarks
If this channel is a voice channel, use ConnectedUsers to retrieve a collection of users who are currently connected to this channel.
Methods
| Improve this Doc View SourceCreateInviteAsync(Nullable<Int32>, Nullable<Int32>, Boolean, Boolean, RequestOptions)
Declaration
public virtual async Task<IInviteMetadata> CreateInviteAsync(int? maxAge, int? maxUses = null, bool isTemporary = false, bool isUnique = false, RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
Nullable<Int32> | maxAge | |
Nullable<Int32> | maxUses | |
Boolean | isTemporary | |
Boolean | isUnique | |
RequestOptions | options |
Returns
Type | Description |
---|---|
Task<IInviteMetadata> |
CreateInviteToApplicationAsync(DefaultApplications, Nullable<Int32>, Nullable<Int32>, Boolean, Boolean, RequestOptions)
Declaration
public virtual async Task<IInviteMetadata> CreateInviteToApplicationAsync(DefaultApplications application, int? maxAge, int? maxUses = null, bool isTemporary = false, bool isUnique = false, RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
DefaultApplications | application | |
Nullable<Int32> | maxAge | |
Nullable<Int32> | maxUses | |
Boolean | isTemporary | |
Boolean | isUnique | |
RequestOptions | options |
Returns
Type | Description |
---|---|
Task<IInviteMetadata> |
CreateInviteToApplicationAsync(UInt64, Nullable<Int32>, Nullable<Int32>, Boolean, Boolean, RequestOptions)
Declaration
public virtual async Task<IInviteMetadata> CreateInviteToApplicationAsync(ulong applicationId, int? maxAge, int? maxUses = null, bool isTemporary = false, bool isUnique = false, RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | applicationId | |
Nullable<Int32> | maxAge | |
Nullable<Int32> | maxUses | |
Boolean | isTemporary | |
Boolean | isUnique | |
RequestOptions | options |
Returns
Type | Description |
---|---|
Task<IInviteMetadata> |
CreateInviteToStreamAsync(IUser, Nullable<Int32>, Nullable<Int32>, Boolean, Boolean, RequestOptions)
Declaration
public virtual async Task<IInviteMetadata> CreateInviteToStreamAsync(IUser user, int? maxAge, int? maxUses = null, bool isTemporary = false, bool isUnique = false, RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
IUser | user | |
Nullable<Int32> | maxAge | |
Nullable<Int32> | maxUses | |
Boolean | isTemporary | |
Boolean | isUnique | |
RequestOptions | options |
Returns
Type | Description |
---|---|
Task<IInviteMetadata> |
CreateThreadAsync(String, ThreadType, ThreadArchiveDuration, IMessage, Nullable<Boolean>, Nullable<Int32>, RequestOptions)
Creates a thread within this ITextChannel.
Declaration
public virtual async Task<SocketThreadChannel> CreateThreadAsync(string name, ThreadType type = default(ThreadType), ThreadArchiveDuration autoArchiveDuration = default(ThreadArchiveDuration), IMessage message = null, bool? invitable = null, int? slowmode = null, RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
String | name | The name of the thread. |
ThreadType | type | The type of the thread.
Note: This parameter is not used if the |
ThreadArchiveDuration | autoArchiveDuration | The duration on which this thread archives after. |
IMessage | message | The message which to start the thread from. |
Nullable<Boolean> | invitable | |
Nullable<Int32> | slowmode | |
RequestOptions | options | The options to be used when sending the request. |
Returns
Type | Description |
---|---|
Task<SocketThreadChannel> | A task that represents the asynchronous create operation. The task result contains a IThreadChannel |
Remarks
When message
is null the thread type will be based off of the
channel its created in. When called on a ITextChannel, it creates a PublicThread.
When called on a INewsChannel, it creates a NewsThread. The id of the created
thread will be the same as the id of the message, and as such a message can only have a
single thread created from it.
CreateWebhookAsync(String, Stream, RequestOptions)
Creates a webhook in this text channel.
Declaration
public virtual Task<RestWebhook> CreateWebhookAsync(string name, Stream avatar = null, RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
String | name | The name of the webhook. |
Stream | avatar | The avatar of the webhook. |
RequestOptions | options | The options to be used when sending the request. |
Returns
Type | Description |
---|---|
Task<RestWebhook> | A task that represents the asynchronous creation operation. The task result contains the newly created webhook. |
DeleteMessageAsync(IMessage, RequestOptions)
Declaration
public virtual Task DeleteMessageAsync(IMessage message, RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
IMessage | message | |
RequestOptions | options |
Returns
Type | Description |
---|---|
Task |
DeleteMessageAsync(UInt64, RequestOptions)
Declaration
public virtual Task DeleteMessageAsync(ulong messageId, RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | messageId | |
RequestOptions | options |
Returns
Type | Description |
---|---|
Task |
DeleteMessagesAsync(IEnumerable<IMessage>, RequestOptions)
Declaration
public virtual Task DeleteMessagesAsync(IEnumerable<IMessage> messages, RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<IMessage> | messages | |
RequestOptions | options |
Returns
Type | Description |
---|---|
Task |
DeleteMessagesAsync(IEnumerable<UInt64>, RequestOptions)
Declaration
public virtual Task DeleteMessagesAsync(IEnumerable<ulong> messageIds, RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<UInt64> | messageIds | |
RequestOptions | options |
Returns
Type | Description |
---|---|
Task |
EnterTypingState(RequestOptions)
Declaration
public virtual IDisposable EnterTypingState(RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
RequestOptions | options |
Returns
Type | Description |
---|---|
IDisposable |
GetActiveThreadsAsync(RequestOptions)
Gets a collection of active threads within this channel.
Declaration
public virtual Task<IReadOnlyCollection<RestThreadChannel>> GetActiveThreadsAsync(RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
RequestOptions | options | The options to be used when sending the request. |
Returns
Type | Description |
---|---|
Task<IReadOnlyCollection<RestThreadChannel>> | A task that represents an asynchronous get operation for retrieving the threads. The task result contains a collection of active threads. |
GetCachedMessage(UInt64)
Gets a cached message from this channel.
Declaration
public virtual SocketMessage GetCachedMessage(ulong id)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | id | The snowflake identifier of the message. |
Returns
Type | Description |
---|---|
SocketMessage | A WebSocket-based message object; null if it does not exist in the cache or if caching is not enabled. |
Remarks
warning
This method requires the use of cache, which is not enabled by default; if caching is not enabled, this method will always return null. Please refer to MessageCacheSize for more details.
This method retrieves the message from the local WebSocket cache and does not send any additional request to Discord. This message may be a message that has been deleted.
GetCachedMessages(IMessage, Direction, Int32)
Gets the last N cached messages starting from a certain message in this message channel.
Declaration
public virtual IReadOnlyCollection<SocketMessage> GetCachedMessages(IMessage fromMessage, Direction dir, int limit = null)
Parameters
Type | Name | Description |
---|---|---|
IMessage | fromMessage | The message to start the fetching from. |
Direction | dir | The direction of which the message should be gotten from. |
Int32 | limit | The number of messages to get. |
Returns
Type | Description |
---|---|
IReadOnlyCollection<SocketMessage> | A read-only collection of WebSocket-based messages. |
Remarks
warning
This method requires the use of cache, which is not enabled by default; if caching is not enabled, this method will always return an empty collection. Please refer to MessageCacheSize for more details.
This method retrieves the message(s) from the local WebSocket cache and does not send any additional request to Discord. This read-only collection may include messages that have been deleted. The maximum number of messages that can be retrieved from this method depends on the MessageCacheSize set.
GetCachedMessages(Int32)
Gets the last N cached messages from this message channel.
Declaration
public virtual IReadOnlyCollection<SocketMessage> GetCachedMessages(int limit = null)
Parameters
Type | Name | Description |
---|---|---|
Int32 | limit | The number of messages to get. |
Returns
Type | Description |
---|---|
IReadOnlyCollection<SocketMessage> | A read-only collection of WebSocket-based messages. |
Remarks
warning
This method requires the use of cache, which is not enabled by default; if caching is not enabled, this method will always return an empty collection. Please refer to MessageCacheSize for more details.
This method retrieves the message(s) from the local WebSocket cache and does not send any additional request to Discord. This read-only collection may include messages that have been deleted. The maximum number of messages that can be retrieved from this method depends on the MessageCacheSize set.
GetCachedMessages(UInt64, Direction, Int32)
Gets the last N cached messages starting from a certain message in this message channel.
Declaration
public virtual IReadOnlyCollection<SocketMessage> GetCachedMessages(ulong fromMessageId, Direction dir, int limit = null)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | fromMessageId | The message ID to start the fetching from. |
Direction | dir | The direction of which the message should be gotten from. |
Int32 | limit | The number of messages to get. |
Returns
Type | Description |
---|---|
IReadOnlyCollection<SocketMessage> | A read-only collection of WebSocket-based messages. |
Remarks
warning
This method requires the use of cache, which is not enabled by default; if caching is not enabled, this method will always return an empty collection. Please refer to MessageCacheSize for more details.
This method retrieves the message(s) from the local WebSocket cache and does not send any additional request to Discord. This read-only collection may include messages that have been deleted. The maximum number of messages that can be retrieved from this method depends on the MessageCacheSize set.
GetInvitesAsync(RequestOptions)
Declaration
public virtual async Task<IReadOnlyCollection<IInviteMetadata>> GetInvitesAsync(RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
RequestOptions | options |
Returns
Type | Description |
---|---|
Task<IReadOnlyCollection<IInviteMetadata>> |
GetMessageAsync(UInt64, RequestOptions)
Gets a message from this message channel.
Declaration
public virtual async Task<IMessage> GetMessageAsync(ulong id, RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | id | The snowflake identifier of the message. |
RequestOptions | options | The options to be used when sending the request. |
Returns
Type | Description |
---|---|
Task<IMessage> | A task that represents an asynchronous get operation for retrieving the message. The task result contains the retrieved message; null if no message is found with the specified identifier. |
Remarks
This method follows the same behavior as described in GetMessageAsync(UInt64, CacheMode, RequestOptions). Please visit its documentation for more details on this method.
GetMessagesAsync(IMessage, Direction, Int32, RequestOptions)
Gets a collection of messages in this channel.
Declaration
public virtual IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = null, RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
IMessage | fromMessage | The starting message to get the messages from. |
Direction | dir | The direction of the messages to be gotten from. |
Int32 | limit | The numbers of message to be gotten from. |
RequestOptions | options | The options to be used when sending the request. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<IReadOnlyCollection<IMessage>> | Paged collection of messages. |
Remarks
This method follows the same behavior as described in
GetMessagesAsync(Int32, RequestOptions)
Gets the last N messages from this message channel.
Declaration
public virtual IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(int limit = null, RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
Int32 | limit | The numbers of message to be gotten from. |
RequestOptions | options | The options to be used when sending the request. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<IReadOnlyCollection<IMessage>> | Paged collection of messages. |
Remarks
This method follows the same behavior as described in
GetMessagesAsync(UInt64, Direction, Int32, RequestOptions)
Gets a collection of messages in this channel.
Declaration
public virtual IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = null, RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | fromMessageId | The ID of the starting message to get the messages from. |
Direction | dir | The direction of the messages to be gotten from. |
Int32 | limit | The numbers of message to be gotten from. |
RequestOptions | options | The options to be used when sending the request. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<IReadOnlyCollection<IMessage>> | Paged collection of messages. |
Remarks
This method follows the same behavior as described in
GetPinnedMessagesAsync(RequestOptions)
Gets a read-only collection of pinned messages in this channel.
Declaration
public virtual Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
RequestOptions | options | The options to be used when sending the request. |
Returns
Type | Description |
---|---|
Task<IReadOnlyCollection<RestMessage>> | A task that represents the asynchronous get operation for retrieving pinned messages in this channel. The task result contains a read-only collection of messages found in the pinned messages. |
Remarks
This method follows the same behavior as described in GetPinnedMessagesAsync(RequestOptions). Please visit its documentation for more details on this method.
GetUser(UInt64)
Declaration
public override SocketGuildUser GetUser(ulong id)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | id |
Returns
Type | Description |
---|---|
SocketGuildUser |
Overrides
| Improve this Doc View SourceGetWebhookAsync(UInt64, RequestOptions)
Gets a webhook available in this text channel.
Declaration
public virtual Task<RestWebhook> GetWebhookAsync(ulong id, RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | id | The identifier of the webhook. |
RequestOptions | options | The options to be used when sending the request. |
Returns
Type | Description |
---|---|
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. |
GetWebhooksAsync(RequestOptions)
Gets the webhooks available in this text channel.
Declaration
public virtual Task<IReadOnlyCollection<RestWebhook>> GetWebhooksAsync(RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
RequestOptions | options | The options to be used when sending the request. |
Returns
Type | Description |
---|---|
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. |
ModifyAsync(Action<TextChannelProperties>, RequestOptions)
Declaration
public virtual Task ModifyAsync(Action<TextChannelProperties> func, RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
Action<TextChannelProperties> | func | |
RequestOptions | options |
Returns
Type | Description |
---|---|
Task |
ModifyMessageAsync(UInt64, Action<MessageProperties>, RequestOptions)
Declaration
public virtual async Task<IUserMessage> ModifyMessageAsync(ulong messageId, Action<MessageProperties> func, RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | messageId | |
Action<MessageProperties> | func | |
RequestOptions | options |
Returns
Type | Description |
---|---|
Task<IUserMessage> |
SendFileAsync(FileAttachment, String, Boolean, Embed, RequestOptions, AllowedMentions, MessageReference, MessageComponent, ISticker[], Embed[], MessageFlags)
Declaration
public virtual Task<RestUserMessage> SendFileAsync(FileAttachment attachment, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = default(MessageFlags))
Parameters
Type | Name | Description |
---|---|---|
FileAttachment | attachment | |
String | text | |
Boolean | isTTS | |
Embed | embed | |
RequestOptions | options | |
AllowedMentions | allowedMentions | |
MessageReference | messageReference | |
MessageComponent | components | |
ISticker[] | stickers | |
Embed[] | embeds | |
MessageFlags | flags |
Returns
Type | Description |
---|---|
Task<RestUserMessage> |
SendFileAsync(Stream, String, String, Boolean, Embed, RequestOptions, Boolean, AllowedMentions, MessageReference, MessageComponent, ISticker[], Embed[], MessageFlags)
Declaration
public virtual Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = default(MessageFlags))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | |
String | filename | |
String | text | |
Boolean | isTTS | |
Embed | embed | |
RequestOptions | options | |
Boolean | isSpoiler | |
AllowedMentions | allowedMentions | |
MessageReference | messageReference | |
MessageComponent | components | |
ISticker[] | stickers | |
Embed[] | embeds | |
MessageFlags | flags |
Returns
Type | Description |
---|---|
Task<RestUserMessage> |
SendFileAsync(String, String, Boolean, Embed, RequestOptions, Boolean, AllowedMentions, MessageReference, MessageComponent, ISticker[], Embed[], MessageFlags)
Declaration
public virtual Task<RestUserMessage> SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = default(MessageFlags))
Parameters
Type | Name | Description |
---|---|---|
String | filePath | |
String | text | |
Boolean | isTTS | |
Embed | embed | |
RequestOptions | options | |
Boolean | isSpoiler | |
AllowedMentions | allowedMentions | |
MessageReference | messageReference | |
MessageComponent | components | |
ISticker[] | stickers | |
Embed[] | embeds | |
MessageFlags | flags |
Returns
Type | Description |
---|---|
Task<RestUserMessage> |
SendFilesAsync(IEnumerable<FileAttachment>, String, Boolean, Embed, RequestOptions, AllowedMentions, MessageReference, MessageComponent, ISticker[], Embed[], MessageFlags)
Declaration
public virtual Task<RestUserMessage> SendFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = default(MessageFlags))
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<FileAttachment> | attachments | |
String | text | |
Boolean | isTTS | |
Embed | embed | |
RequestOptions | options | |
AllowedMentions | allowedMentions | |
MessageReference | messageReference | |
MessageComponent | components | |
ISticker[] | stickers | |
Embed[] | embeds | |
MessageFlags | flags |
Returns
Type | Description |
---|---|
Task<RestUserMessage> |
SendMessageAsync(String, Boolean, Embed, RequestOptions, AllowedMentions, MessageReference, MessageComponent, ISticker[], Embed[], MessageFlags)
Declaration
public virtual Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = default(MessageFlags))
Parameters
Type | Name | Description |
---|---|---|
String | text | |
Boolean | isTTS | |
Embed | embed | |
RequestOptions | options | |
AllowedMentions | allowedMentions | |
MessageReference | messageReference | |
MessageComponent | components | |
ISticker[] | stickers | |
Embed[] | embeds | |
MessageFlags | flags |
Returns
Type | Description |
---|---|
Task<RestUserMessage> |
SyncPermissionsAsync(RequestOptions)
Declaration
public virtual Task SyncPermissionsAsync(RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
RequestOptions | options |
Returns
Type | Description |
---|---|
Task |
TriggerTypingAsync(RequestOptions)
Declaration
public virtual Task TriggerTypingAsync(RequestOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
RequestOptions | options |
Returns
Type | Description |
---|---|
Task |