Class RestGroupChannel
Represents a REST-based group-message channel.
public class RestGroupChannel : RestChannel, IUpdateable, IGroupChannel, IRestPrivateChannel, IPrivateChannel, IRestMessageChannel, IMessageChannel, IRestAudioChannel, IAudioChannel, IChannel, ISnowflakeEntity, IEntity<ulong>
- Inheritance
-
RestGroupChannel
- Implements
- Inherited Members
- Extension Methods
Properties
Name
Gets the name of this channel.
public string Name { get; }
Property Value
- string
A string containing the name of this channel.
RTCRegion
Gets the RTC region for this audio channel.
public string RTCRegion { get; }
Property Value
Remarks
This property can be null.
Recipients
public IReadOnlyCollection<RestGroupUser> Recipients { get; }
Property Value
Users
public IReadOnlyCollection<RestGroupUser> Users { get; }
Property Value
Methods
DeleteMessageAsync(IMessage, RequestOptions)
Deletes a message based on the provided message in this channel.
public Task DeleteMessageAsync(IMessage message, RequestOptions options = null)
Parameters
messageIMessageThe message that would be removed.
optionsRequestOptionsThe options to be used when sending the request.
Returns
- Task
A task that represents the asynchronous removal operation.
DeleteMessageAsync(ulong, RequestOptions)
Deletes a message.
public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null)
Parameters
messageIdulongThe snowflake identifier of the message that would be removed.
optionsRequestOptionsThe options to be used when sending the request.
Returns
- Task
A task that represents the asynchronous removal operation.
EnterTypingState(RequestOptions)
Continuously broadcasts the "user is typing" message to all users in this channel until the returned object is disposed.
public IDisposable EnterTypingState(RequestOptions options = null)
Parameters
optionsRequestOptionsThe options to be used when sending the request.
Returns
- IDisposable
A disposable object that, upon its disposal, will stop the client from broadcasting its typing state in this channel.
Examples
The following example keeps the client in the typing state until LongRunningAsync has finished.
using (channel.EnterTypingState())
await LongRunningAsync();
GetMessageAsync(ulong, RequestOptions)
Gets a message from this message channel.
public Task<RestMessage> GetMessageAsync(ulong id, RequestOptions options = null)
Parameters
idulongThe snowflake identifier of the message.
optionsRequestOptionsThe options to be used when sending the request.
Returns
- Task<RestMessage>
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(ulong, CacheMode, RequestOptions). Please visit its documentation for more details on this method.
GetMessagesAsync(IMessage, Direction, int, RequestOptions)
Gets a collection of messages in this channel.
public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = 100, RequestOptions options = null)
Parameters
fromMessageIMessageThe starting message to get the messages from.
dirDirectionThe direction of the messages to be gotten from.
limitintThe numbers of message to be gotten from.
optionsRequestOptionsThe options to be used when sending the request.
Returns
- IAsyncEnumerable<IReadOnlyCollection<RestMessage>>
Paged collection of messages.
Remarks
This method follows the same behavior as described in GetMessagesAsync(IMessage, Direction, int, CacheMode, RequestOptions). Please visit its documentation for more details on this method.
GetMessagesAsync(int, RequestOptions)
Gets the last N messages from this message channel.
public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(int limit = 100, RequestOptions options = null)
Parameters
limitintThe numbers of message to be gotten from.
optionsRequestOptionsThe options to be used when sending the request.
Returns
- IAsyncEnumerable<IReadOnlyCollection<RestMessage>>
Paged collection of messages.
Remarks
This method follows the same behavior as described in GetMessagesAsync(int, CacheMode, RequestOptions). Please visit its documentation for more details on this method.
GetMessagesAsync(ulong, Direction, int, RequestOptions)
Gets a collection of messages in this channel.
public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = 100, RequestOptions options = null)
Parameters
fromMessageIdulongThe ID of the starting message to get the messages from.
dirDirectionThe direction of the messages to be gotten from.
limitintThe numbers of message to be gotten from.
optionsRequestOptionsThe options to be used when sending the request.
Returns
- IAsyncEnumerable<IReadOnlyCollection<RestMessage>>
Paged collection of messages.
Remarks
This method follows the same behavior as described in GetMessagesAsync(ulong, Direction, int, CacheMode, RequestOptions). Please visit its documentation for more details on this method.
GetPinnedMessagesAsync(RequestOptions)
Gets a collection of pinned messages in this channel.
public Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null)
Parameters
optionsRequestOptionsThe options to be used when sending the request.
Returns
- Task<IReadOnlyCollection<RestMessage>>
A task that represents the asynchronous get operation for retrieving pinned messages in this channel. The task result contains a 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(ulong)
public RestUser GetUser(ulong id)
Parameters
idulong
Returns
LeaveAsync(RequestOptions)
Leaves this group.
public Task LeaveAsync(RequestOptions options = null)
Parameters
optionsRequestOptionsThe options to be used when sending the request.
Returns
- Task
A task that represents the asynchronous leave operation.
ModifyMessageAsync(ulong, Action<MessageProperties>, RequestOptions)
Modifies a message.
public Task<IUserMessage> ModifyMessageAsync(ulong messageId, Action<MessageProperties> func, RequestOptions options = null)
Parameters
messageIdulongThe snowflake identifier of the message that would be changed.
funcAction<MessageProperties>A delegate containing the properties to modify the message with.
optionsRequestOptionsThe options to be used when sending the request.
Returns
- Task<IUserMessage>
A task that represents the asynchronous modification operation.
Remarks
This method modifies this message with the specified properties. To see an example of this method and what properties are available, please refer to MessageProperties.
SendFileAsync(FileAttachment, string, bool, Embed, RequestOptions, AllowedMentions, MessageReference, MessageComponent, ISticker[], Embed[], MessageFlags, PollProperties)
Sends a file to this message channel with an optional caption.
public 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 = MessageFlags.None, PollProperties poll = null)
Parameters
attachmentFileAttachmentThe attachment containing the file and description.
textstringThe message to be sent.
isTTSboolWhether the message should be read aloud by Discord or not.
embedEmbedoptionsRequestOptionsThe options to be used when sending the request.
allowedMentionsAllowedMentionsSpecifies if notifications are sent for mentioned users and roles in the message
text. If null, all mentioned roles and users will be notified.messageReferenceMessageReferenceThe message references to be included. Used to reply to specific messages.
componentsMessageComponentThe message components to be included with this message. Used for interactions.
stickersISticker[]A collection of stickers to send with the file.
embedsEmbed[]A array of Embeds to send with this response. Max 10.
flagsMessageFlagsA message flag to be applied to the sent message, only SuppressEmbeds and SuppressNotification is permitted.
pollPollPropertiesA poll to send with the message.
Returns
- Task<RestUserMessage>
A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message.
Remarks
This method sends a file as if you are uploading an attachment directly from your Discord client.
Exceptions
- ArgumentOutOfRangeException
Message content is too long, length must be less or equal to MaxMessageSize.
- ArgumentException
The only valid MessageFlags are SuppressEmbeds and None.
SendFileAsync(Stream, string, string, bool, Embed, RequestOptions, bool, AllowedMentions, MessageReference, MessageComponent, ISticker[], Embed[], MessageFlags, PollProperties)
Sends a file to this message channel with an optional caption.
public 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 = MessageFlags.None, PollProperties poll = null)
Parameters
streamStreamThe Stream of the file to be sent.
filenamestringThe name of the attachment.
textstringThe message to be sent.
isTTSboolWhether the message should be read aloud by Discord or not.
embedEmbedoptionsRequestOptionsThe options to be used when sending the request.
isSpoilerboolWhether the message attachment should be hidden as a spoiler.
allowedMentionsAllowedMentionsSpecifies if notifications are sent for mentioned users and roles in the message
text. If null, all mentioned roles and users will be notified.messageReferenceMessageReferenceThe message references to be included. Used to reply to specific messages.
componentsMessageComponentThe message components to be included with this message. Used for interactions.
stickersISticker[]A collection of stickers to send with the file.
embedsEmbed[]A array of Embeds to send with this response. Max 10.
flagsMessageFlagsA message flag to be applied to the sent message, only SuppressEmbeds and SuppressNotification is permitted.
pollPollPropertiesA poll to send with the message.
Returns
- Task<RestUserMessage>
A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message.
Examples
The following example uploads a streamed image that will be called b1nzy.jpg embedded inside a
rich embed to the channel.
using (var b1nzyStream = await httpClient.GetStreamAsync("https://example.com/b1nzy"))
await channel.SendFileAsync(b1nzyStream, "b1nzy.jpg",
embed: new EmbedBuilder { ImageUrl = "attachment://b1nzy.jpg" }.Build());
Remarks
This method sends a file as if you are uploading an attachment directly from your Discord client.
Exceptions
- ArgumentOutOfRangeException
Message content is too long, length must be less or equal to MaxMessageSize.
- ArgumentException
The only valid MessageFlags are SuppressEmbeds and None.
SendFileAsync(string, string, bool, Embed, RequestOptions, bool, AllowedMentions, MessageReference, MessageComponent, ISticker[], Embed[], MessageFlags, PollProperties)
Sends a file to this message channel with an optional caption.
public 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 = MessageFlags.None, PollProperties poll = null)
Parameters
filePathstringThe file path of the file.
textstringThe message to be sent.
isTTSboolWhether the message should be read aloud by Discord or not.
embedEmbedoptionsRequestOptionsThe options to be used when sending the request.
isSpoilerboolWhether the message attachment should be hidden as a spoiler.
allowedMentionsAllowedMentionsSpecifies if notifications are sent for mentioned users and roles in the message
text. If null, all mentioned roles and users will be notified.messageReferenceMessageReferenceThe message references to be included. Used to reply to specific messages.
componentsMessageComponentThe message components to be included with this message. Used for interactions.
stickersISticker[]A collection of stickers to send with the file.
embedsEmbed[]A array of Embeds to send with this response. Max 10.
flagsMessageFlagsA message flag to be applied to the sent message, only SuppressEmbeds and SuppressNotification is permitted.
pollPollPropertiesA poll to send with the message.
Returns
- Task<RestUserMessage>
A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message.
Examples
The following example uploads a local file called wumpus.txt along with the text
good discord boi to the channel.
await channel.SendFileAsync("wumpus.txt", "good discord boi");
The following example uploads a local image called b1nzy.jpg embedded inside a rich embed to the
channel.
await channel.SendFileAsync("b1nzy.jpg",
embed: new EmbedBuilder { ImageUrl = "attachment://b1nzy.jpg" }.Build());
Remarks
This method sends a file as if you are uploading an attachment directly from your Discord client.
Exceptions
- ArgumentException
filePathis a zero-length string, contains only white space, or contains one or more invalid characters as defined by GetInvalidPathChars().- ArgumentNullException
filePathis null.- PathTooLongException
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
- DirectoryNotFoundException
The specified path is invalid, (for example, it is on an unmapped drive).
- UnauthorizedAccessException
filePathspecified a directory.-or- The caller does not have the required permission.- FileNotFoundException
The file specified in
filePathwas not found.- NotSupportedException
filePathis in an invalid format.- IOException
An I/O error occurred while opening the file.
- ArgumentOutOfRangeException
Message content is too long, length must be less or equal to MaxMessageSize.
- ArgumentException
The only valid MessageFlags are SuppressEmbeds and None.
SendFilesAsync(IEnumerable<FileAttachment>, string, bool, Embed, RequestOptions, AllowedMentions, MessageReference, MessageComponent, ISticker[], Embed[], MessageFlags, PollProperties)
Sends a collection of files to this message channel.
public 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 = MessageFlags.None, PollProperties poll = null)
Parameters
attachmentsIEnumerable<FileAttachment>A collection of attachments to upload.
textstringThe message to be sent.
isTTSboolWhether the message should be read aloud by Discord or not.
embedEmbedoptionsRequestOptionsThe options to be used when sending the request.
allowedMentionsAllowedMentionsSpecifies if notifications are sent for mentioned users and roles in the message
text. If null, all mentioned roles and users will be notified.messageReferenceMessageReferenceThe message references to be included. Used to reply to specific messages.
componentsMessageComponentThe message components to be included with this message. Used for interactions.
stickersISticker[]A collection of stickers to send with the file.
embedsEmbed[]A array of Embeds to send with this response. Max 10.
flagsMessageFlagsA message flag to be applied to the sent message, only SuppressEmbeds and SuppressNotification is permitted.
pollPollPropertiesA poll to send with the message.
Returns
- Task<RestUserMessage>
A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message.
Remarks
This method sends files as if you are uploading attachments directly from your Discord client.
Exceptions
- ArgumentOutOfRangeException
Message content is too long, length must be less or equal to MaxMessageSize.
- ArgumentException
The only valid MessageFlags are SuppressEmbeds and None.
SendMessageAsync(string, bool, Embed, RequestOptions, AllowedMentions, MessageReference, MessageComponent, ISticker[], Embed[], MessageFlags, PollProperties)
Sends a message to this message channel.
public 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 = MessageFlags.None, PollProperties poll = null)
Parameters
textstringThe message to be sent.
isTTSboolDetermines whether the message should be read aloud by Discord or not.
embedEmbedoptionsRequestOptionsThe options to be used when sending the request.
allowedMentionsAllowedMentionsSpecifies if notifications are sent for mentioned users and roles in the message
text. If null, all mentioned roles and users will be notified.messageReferenceMessageReferenceThe message references to be included. Used to reply to specific messages.
componentsMessageComponentThe message components to be included with this message. Used for interactions.
stickersISticker[]A collection of stickers to send with the message.
embedsEmbed[]A array of Embeds to send with this response. Max 10.
flagsMessageFlagsA message flag to be applied to the sent message, only SuppressEmbeds and SuppressNotification is permitted.
pollPollPropertiesA poll to send with the message.
Returns
- Task<RestUserMessage>
A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message.
Examples
The following example sends a message with the current system time in RFC 1123 format to the channel and deletes itself after 5 seconds.
var message = await channel.SendMessageAsync(DateTimeOffset.UtcNow.ToString("R"));
await Task.Delay(TimeSpan.FromSeconds(5))
.ContinueWith(x => message.DeleteAsync());
Exceptions
- ArgumentOutOfRangeException
Message content is too long, length must be less or equal to MaxMessageSize.
- ArgumentException
The only valid MessageFlags are SuppressEmbeds and None.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
TriggerTypingAsync(RequestOptions)
Broadcasts the "user is typing" message to all users in this channel, lasting 10 seconds.
public Task TriggerTypingAsync(RequestOptions options = null)
Parameters
optionsRequestOptionsThe options to be used when sending the request.
Returns
- Task
A task that represents the asynchronous operation that triggers the broadcast.
UpdateAsync(RequestOptions)
Updates this object's properties with its current state.
public override Task UpdateAsync(RequestOptions options = null)
Parameters
optionsRequestOptionsThe options to be used when sending the request.