Class DiscordChannel
Represents a discord channel.
Inheritance
Namespace: DisCatSharp.Entities
Assembly: DisCatSharp.dll
Syntax
public class DiscordChannel : SnowflakeObject, IEquatable<DiscordChannel>
Properties
| Improve this Doc View SourceAvailableTags
List of available tags for forum posts.
Declaration
public List<ForumPostTag> AvailableTags { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<ForumPostTag> |
BannerHash
Gets this channel's banner hash, when applicable.
Declaration
public string BannerHash { get; }
Property Value
Type | Description |
---|---|
System.String |
BannerUrl
Gets this channel's banner in url form.
Declaration
public string BannerUrl { get; }
Property Value
Type | Description |
---|---|
System.String |
Bitrate
Gets this channel's bitrate. This is applicable to voice channels only.
Declaration
public int? Bitrate { get; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Int32> |
Children
Gets this channel's children. This applies only to channel categories.
Declaration
public IReadOnlyList<DiscordChannel> Children { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyList<DiscordChannel> |
DefaultAutoArchiveDuration
Gets this channel's default duration for newly created threads, in minutes, to automatically archive the thread after recent activity.
Declaration
public ThreadAutoArchiveDuration? DefaultAutoArchiveDuration { get; }
Property Value
Type | Description |
---|---|
System.Nullable<ThreadAutoArchiveDuration> |
Flags
Gets the flags of this channel.
Declaration
public ChannelFlags Flags { get; }
Property Value
Type | Description |
---|---|
ChannelFlags |
Guild
Gets the guild to which this channel belongs.
Declaration
public DiscordGuild Guild { get; }
Property Value
Type | Description |
---|---|
DiscordGuild |
GuildId
Gets ID of the guild to which this channel belongs.
Declaration
public ulong? GuildId { get; }
Property Value
Type | Description |
---|---|
System.Nullable<System.UInt64> |
IsCategory
Gets whether this channel is a channel category.
Declaration
public bool IsCategory { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsNsfw
Gets whether this channel is an NSFW channel.
Declaration
public bool IsNsfw { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsPrivate
Gets whether this channel is a DM channel.
Declaration
public bool IsPrivate { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsStage
Gets whether this channel is a stage channel.
Declaration
public bool IsStage { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
LastMessageId
Gets the ID of the last message sent in this channel. This is applicable to text channels only.
Declaration
public ulong? LastMessageId { get; }
Property Value
Type | Description |
---|---|
System.Nullable<System.UInt64> |
LastPinTimestamp
Gets when the last pinned message was pinned.
Declaration
public DateTimeOffset? LastPinTimestamp { get; }
Property Value
Type | Description |
---|---|
System.Nullable<System.DateTimeOffset> |
Mention
Gets this channel's mention string.
Declaration
public string Mention { get; }
Property Value
Type | Description |
---|---|
System.String |
Name
Gets the name of this channel.
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
System.String |
Parent
Gets the category that contains this channel.
Declaration
public DiscordChannel Parent { get; }
Property Value
Type | Description |
---|---|
DiscordChannel |
ParentId
Gets ID of the category that contains this channel.
Declaration
public ulong? ParentId { get; }
Property Value
Type | Description |
---|---|
System.Nullable<System.UInt64> |
PermissionOverwrites
Gets a collection of permission overwrites for this channel.
Declaration
public IReadOnlyList<DiscordOverwrite> PermissionOverwrites { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyList<DiscordOverwrite> |
PerUserRateLimit
Gets the slow mode delay configured for this channel.
All bots, as well as users with ManageChannels or ManageMessages permissions in the channel are exempt from slow mode.
Declaration
public int? PerUserRateLimit { get; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Int32> |
Position
Gets the position of this channel.
Declaration
public int Position { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
QualityMode
Gets this channel's video quality mode. This is applicable to voice channels only.
Declaration
public VideoQualityMode? QualityMode { get; }
Property Value
Type | Description |
---|---|
System.Nullable<VideoQualityMode> |
RtcRegion
Gets this channel's region override (if voice channel).
Declaration
public DiscordVoiceRegion RtcRegion { get; }
Property Value
Type | Description |
---|---|
DiscordVoiceRegion |
Template
Gets the template for new posts in this channel. Applicable if forum channel.
Declaration
public string Template { get; }
Property Value
Type | Description |
---|---|
System.String |
Topic
Gets the channel's topic. This is applicable to text channels only.
Declaration
public string Topic { get; }
Property Value
Type | Description |
---|---|
System.String |
Type
Gets the type of this channel.
Declaration
public ChannelType Type { get; }
Property Value
Type | Description |
---|---|
ChannelType |
UserLimit
Gets this channel's user limit. This is applicable to voice channels only.
Declaration
public int? UserLimit { get; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Int32> |
UserPermissions
Only sent on the resolved channels of interaction responses for application commands. Gets the permissions of the user in this channel who invoked the command.
Declaration
public Permissions? UserPermissions { get; }
Property Value
Type | Description |
---|---|
System.Nullable<Permissions> |
Users
Gets the list of members currently in the channel (if voice channel), or members who can see the channel (otherwise).
Declaration
public virtual IReadOnlyList<DiscordMember> Users { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyList<DiscordMember> |
Methods
| Improve this Doc View SourceAddOverwriteAsync(DiscordMember, Permissions, Permissions, String)
Adds a channel permission overwrite for specified member.
Declaration
public Task AddOverwriteAsync(DiscordMember member, Permissions allow = Permissions.None, Permissions deny = Permissions.None, string reason = null)
Parameters
Type | Name | Description |
---|---|---|
DiscordMember | member | The member to have the permission added. |
Permissions | allow | The permissions to allow. |
Permissions | deny | The permissions to deny. |
System.String | reason | Reason for audit logs. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the ManageRoles permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
AddOverwriteAsync(DiscordRole, Permissions, Permissions, String)
Adds a channel permission overwrite for specified role.
Declaration
public Task AddOverwriteAsync(DiscordRole role, Permissions allow = Permissions.None, Permissions deny = Permissions.None, string reason = null)
Parameters
Type | Name | Description |
---|---|---|
DiscordRole | role | The role to have the permission added. |
Permissions | allow | The permissions to allow. |
Permissions | deny | The permissions to deny. |
System.String | reason | Reason for audit logs. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the ManageRoles permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
CloneAsync(String)
Clones this channel. This operation will create a channel with identical settings to this one. Note that this will not copy messages.
Declaration
public async Task<DiscordChannel> CloneAsync(string reason = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | reason | Reason for audit logs. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<DiscordChannel> | Newly-created channel. |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the ManageChannels permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
CloseStageAsync(String)
Closes a stage.
Declaration
public async Task CloseStageAsync(string reason = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | reason | Audit log reason. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the ManageChannels permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
CreateInviteAsync(Int32, Int32, Boolean, Boolean, Nullable<TargetType>, Nullable<TargetActivity>, Nullable<UInt64>, String)
Create a new invite object
Declaration
public Task<DiscordInvite> CreateInviteAsync(int maxAge = 86400, int maxUses = 0, bool temporary = false, bool unique = false, TargetType? targetType = null, TargetActivity? targetApplication = null, ulong? targetUser = null, string reason = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | maxAge | Duration of invite in seconds before expiry, or 0 for never. Defaults to 86400. |
System.Int32 | maxUses | Max number of uses or 0 for unlimited. Defaults to 0 |
System.Boolean | temporary | Whether this invite should be temporary. Defaults to false. |
System.Boolean | unique | Whether this invite should be unique. Defaults to false. |
System.Nullable<TargetType> | targetType | The target type. Defaults to null. |
System.Nullable<TargetActivity> | targetApplication | The target activity. Defaults to null. |
System.Nullable<System.UInt64> | targetUser | The target user id. Defaults to null. |
System.String | reason | The audit log reason. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<DiscordInvite> |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the CreateInstantInvite permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
CreateScheduledEventAsync(String, DateTimeOffset, String, Optional<Stream>, String)
Creates a scheduled event based on the channel type.
Declaration
public async Task<DiscordScheduledEvent> CreateScheduledEventAsync(string name, DateTimeOffset scheduledStartTime, string description = null, Optional<Stream> coverImage = default(Optional<Stream>), string reason = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name. |
System.DateTimeOffset | scheduledStartTime | The scheduled start time. |
System.String | description | The description. |
Optional<System.IO.Stream> | coverImage | The cover image. |
System.String | reason | The reason. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<DiscordScheduledEvent> | A scheduled event. |
Exceptions
Type | Condition |
---|---|
NotFoundException | Thrown when the resource does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
CreateThreadAsync(String, ThreadAutoArchiveDuration, ChannelType, Nullable<Int32>, String)
Creates a thread. Depending on whether it is created inside an News or an Text it is either an NewsThread or an PublicThread. Depending on whether the ChannelType is set to PrivateThread it is either an PrivateThread or an PublicThread (default).
Declaration
public async Task<DiscordThreadChannel> CreateThreadAsync(string name, ThreadAutoArchiveDuration autoArchiveDuration = ThreadAutoArchiveDuration.OneHour, ChannelType type = ChannelType.PublicThread, int? rateLimitPerUser = null, string reason = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the thread. |
ThreadAutoArchiveDuration | autoArchiveDuration | ThreadAutoArchiveDuration till it gets archived. Defaults to OneHour. |
ChannelType | type | Can be either an PrivateThread, NewsThread or an PublicThread. |
System.Nullable<System.Int32> | rateLimitPerUser | The per user ratelimit, aka slowdown. |
System.String | reason | Audit log reason. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<DiscordThreadChannel> | The created thread. |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the CreatePublicThreads or SendMessagesInThreads or if creating a private thread the CreatePrivateThreads permission. |
NotFoundException | Thrown when the guild hasn't enabled threads atm. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
System.NotSupportedException | Thrown when the ThreadAutoArchiveDuration cannot be modified. This happens, when the guild hasn't reached a certain boost PremiumTier. Or if CanCreatePrivateThreads is not enabled for guild. This happens, if the guild does not have TierTwo |
CreateWebhookAsync(String, Optional<Stream>, String)
Create a new webhook.
Declaration
public async Task<DiscordWebhook> CreateWebhookAsync(string name, Optional<Stream> avatar = default(Optional<Stream>), string reason = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the webhook. |
Optional<System.IO.Stream> | avatar | The image for the default webhook avatar. |
System.String | reason | Reason for audit logs. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<DiscordWebhook> |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the ManageWebhooks permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
CrosspostMessageAsync(DiscordMessage)
Publishes a message in a news channel to following channels.
Declaration
public Task<DiscordMessage> CrosspostMessageAsync(DiscordMessage message)
Parameters
Type | Name | Description |
---|---|---|
DiscordMessage | message | Message to publish. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<DiscordMessage> |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when the message has already been crossposted. |
UnauthorizedException | Thrown when the current user doesn't have ManageWebhooks and/or SendMessages |
DeleteAsync(String)
Deletes a guild channel
Declaration
public Task DeleteAsync(string reason = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | reason | Reason for audit logs. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the ManageChannels permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
DeleteMessageAsync(DiscordMessage, String)
Deletes a message
Declaration
public Task DeleteMessageAsync(DiscordMessage message, string reason = null)
Parameters
Type | Name | Description |
---|---|---|
DiscordMessage | message | The message to be deleted. |
System.String | reason | Reason for audit logs. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the ManageMessages permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
DeleteMessagesAsync(IEnumerable<DiscordMessage>, String)
Deletes multiple messages if they are less than 14 days old. If they are older, none of the messages will be deleted and you will receive a BadRequestException error.
Declaration
public async Task DeleteMessagesAsync(IEnumerable<DiscordMessage> messages, string reason = null)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<DiscordMessage> | messages | A collection of messages to delete. |
System.String | reason | Reason for audit logs. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the ManageMessages permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
DeleteOverwriteAsync(DiscordMember, String)
Deletes a channel permission overwrite for specified member.
Declaration
public Task DeleteOverwriteAsync(DiscordMember member, string reason = null)
Parameters
Type | Name | Description |
---|---|---|
DiscordMember | member | The member to have the permission deleted. |
System.String | reason | Reason for audit logs. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the ManageRoles permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
DeleteOverwriteAsync(DiscordRole, String)
Deletes a channel permission overwrite for specified role.
Declaration
public Task DeleteOverwriteAsync(DiscordRole role, string reason = null)
Parameters
Type | Name | Description |
---|---|---|
DiscordRole | role | The role to have the permission deleted. |
System.String | reason | Reason for audit logs. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the ManageRoles permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
Equals(DiscordChannel)
Checks whether this DiscordChannel is equal to another DiscordChannel.
Declaration
public bool Equals(DiscordChannel e)
Parameters
Type | Name | Description |
---|---|---|
DiscordChannel | e | DiscordChannel to compare to. |
Returns
Type | Description |
---|---|
System.Boolean | Whether the DiscordChannel is equal to this DiscordChannel. |
Equals(Object)
Checks whether this DiscordChannel is equal to another object.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | Object to compare to. |
Returns
Type | Description |
---|---|
System.Boolean | Whether the object is equal to this DiscordChannel. |
Overrides
FollowAsync(DiscordChannel)
Follows a news channel.
Declaration
public Task<DiscordFollowedChannel> FollowAsync(DiscordChannel targetChannel)
Parameters
Type | Name | Description |
---|---|---|
DiscordChannel | targetChannel | Channel to crosspost messages to. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<DiscordFollowedChannel> |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when trying to follow a non-news channel. |
UnauthorizedException | Thrown when the current user doesn't have ManageWebhooks on the target channel. |
GetHashCode()
Gets the hash code for this DiscordChannel.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | The hash code for this DiscordChannel. |
Overrides
GetInvitesAsync()
Returns a list of invite objects
Declaration
public Task<IReadOnlyList<DiscordInvite>> GetInvitesAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<DiscordInvite>> |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the CreateInstantInvite permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
GetJoinedPrivateArchivedThreadsAsync(Nullable<UInt64>, Nullable<Int32>)
Gets joined archived private threads. Can contain more threads. If the result's value 'HasMore' is true, you need to recall this function to get older threads.
Declaration
public async Task<DiscordThreadResult> GetJoinedPrivateArchivedThreadsAsync(ulong? before, int? limit)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.UInt64> | before | Get threads created before this thread id. |
System.Nullable<System.Int32> | limit | Defines the limit of returned DiscordThreadResult. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<DiscordThreadResult> |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the ReadMessageHistory permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
GetMaxPosition()
Gets the maximum available position to move the channel to. This can contain outdated information.
Declaration
public int GetMaxPosition()
Returns
Type | Description |
---|---|
System.Int32 |
GetMessageAsync(UInt64)
Returns a specific message
Declaration
public async Task<DiscordMessage> GetMessageAsync(ulong id)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | id | The id of the message |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<DiscordMessage> |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the ReadMessageHistory permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
GetMessagesAfterAsync(UInt64, Int32)
Returns a list of messages after a certain message. The amount of messages to fetch. Message to fetch after from.
Declaration
public Task<IReadOnlyList<DiscordMessage>> GetMessagesAfterAsync(ulong after, int limit = 100)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | after | |
System.Int32 | limit |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<DiscordMessage>> |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the AccessChannels permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
GetMessagesAroundAsync(UInt64, Int32)
Returns a list of messages around a certain message. The amount of messages to fetch. Message to fetch around from.
Declaration
public Task<IReadOnlyList<DiscordMessage>> GetMessagesAroundAsync(ulong around, int limit = 100)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | around | |
System.Int32 | limit |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<DiscordMessage>> |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the AccessChannels permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
GetMessagesAsync(Int32)
Returns a list of messages from the last message in the channel. The amount of messages to fetch.
Declaration
public Task<IReadOnlyList<DiscordMessage>> GetMessagesAsync(int limit = 100)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | limit |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<DiscordMessage>> |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the AccessChannels permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
GetMessagesBeforeAsync(UInt64, Int32)
Returns a list of messages before a certain message. The amount of messages to fetch. Message to fetch before from.
Declaration
public Task<IReadOnlyList<DiscordMessage>> GetMessagesBeforeAsync(ulong before, int limit = 100)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | before | |
System.Int32 | limit |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<DiscordMessage>> |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the AccessChannels permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
GetMinPosition()
Gets the minimum available position to move the channel to.
Declaration
public int GetMinPosition()
Returns
Type | Description |
---|---|
System.Int32 |
GetPinnedMessagesAsync()
Returns all pinned messages.
Declaration
public Task<IReadOnlyList<DiscordMessage>> GetPinnedMessagesAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<DiscordMessage>> |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the AccessChannels permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
GetPrivateArchivedThreadsAsync(Nullable<UInt64>, Nullable<Int32>)
Gets archived private threads. Can contain more threads. If the result's value 'HasMore' is true, you need to recall this function to get older threads.
Declaration
public async Task<DiscordThreadResult> GetPrivateArchivedThreadsAsync(ulong? before, int? limit)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.UInt64> | before | Get threads created before this thread id. |
System.Nullable<System.Int32> | limit | Defines the limit of returned DiscordThreadResult. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<DiscordThreadResult> |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the ManageThreads or ReadMessageHistory permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
GetPublicArchivedThreadsAsync(Nullable<UInt64>, Nullable<Int32>)
Gets archived public threads. Can contain more threads. If the result's value 'HasMore' is true, you need to recall this function to get older threads.
Declaration
public async Task<DiscordThreadResult> GetPublicArchivedThreadsAsync(ulong? before, int? limit)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.UInt64> | before | Get threads created before this thread id. |
System.Nullable<System.Int32> | limit | Defines the limit of returned DiscordThreadResult. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<DiscordThreadResult> |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the ReadMessageHistory permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
GetStageAsync()
Gets a stage.
Declaration
public async Task<DiscordStageInstance> GetStageAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<DiscordStageInstance> | The requested stage. |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the AccessChannels or UseVoice permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
GetWebhooksAsync()
Returns a list of webhooks.
Declaration
public Task<IReadOnlyList<DiscordWebhook>> GetWebhooksAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<DiscordWebhook>> |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the ManageWebhooks permission. |
NotFoundException | Thrown when the channel does not exist. |
ServerErrorException | Thrown when Discord is unable to process the request. |
ModifyAsync(Action<ChannelEditModel>)
Modifies the current channel.
Declaration
public Task ModifyAsync(Action<ChannelEditModel> action)
Parameters
Type | Name | Description |
---|---|---|
System.Action<ChannelEditModel> | action | Action to perform on this channel |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the ManageChannels. |
System.NotSupportedException | Thrown when the client does not have the correct PremiumTier for modifying the ThreadAutoArchiveDuration. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
ModifyParentAsync(DiscordChannel, Nullable<Boolean>, String)
Updates the channel parent, moving the channel to the bottom of the new category.
Declaration
public Task ModifyParentAsync(DiscordChannel newParent, bool? lockPermissions = null, string reason = null)
Parameters
Type | Name | Description |
---|---|---|
DiscordChannel | newParent | New parent for channel. Use RemoveParentAsync(String) to remove from parent. |
System.Nullable<System.Boolean> | lockPermissions | Sync permissions with parent. Defaults to null. |
System.String | reason | Reason for audit logs. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the ManageChannels permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
ModifyPositionAsync(Int32, String)
Updates the channel position when it doesn't have a category.
Use ModifyParentAsync(DiscordChannel, Nullable<Boolean>, String) for moving to other categories. Use RemoveParentAsync(String) to move out of a category. Use ModifyPositionInCategoryAsync(Int32, String) for moving within a category.
Declaration
public Task ModifyPositionAsync(int position, string reason = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | position | Position the channel should be moved to. |
System.String | reason | Reason for audit logs. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the ManageChannels permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
ModifyPositionInCategoryAsync(Int32, String)
Updates the channel position within it's own category.
Use ModifyParentAsync(DiscordChannel, Nullable<Boolean>, String) for moving to other categories. Use RemoveParentAsync(String) to move out of a category. Use ModifyPositionAsync(Int32, String) to move channels outside a category.
Declaration
public async Task ModifyPositionInCategoryAsync(int position, string reason = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | position | The position. |
System.String | reason | The reason. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the ManageChannels permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
System.IndexOutOfRangeException | Thrown when |
System.ArgumentException | Thrown when function is called on a channel without a parent channel. |
ModifyPositionInCategorySmartAsync(String, Int32, String)
Updates the channel position within it's own category. Valid modes: '+' or 'down' to move a channel down | '-' or 'up' to move a channel up.
Use ModifyParentAsync(DiscordChannel, Nullable<Boolean>, String) for moving to other categories. Use RemoveParentAsync(String) to move out of a category. Use ModifyPositionAsync(Int32, String) to move channels outside a category.
Declaration
public Task ModifyPositionInCategorySmartAsync(string mode, int position, string reason = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | mode | The mode. Valid: '+' or 'down' to move a channel down | '-' or 'up' to move a channel up |
System.Int32 | position | The position. |
System.String | reason | The reason. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the ManageChannels permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
System.IndexOutOfRangeException | Thrown when |
System.ArgumentException | Thrown when function is called on a channel without a parent channel, a wrong mode is given or given position is zero. |
ModifyStageAsync(Optional<String>, Optional<StagePrivacyLevel>, String)
Modifies a stage topic.
Declaration
public async Task ModifyStageAsync(Optional<string> topic, Optional<StagePrivacyLevel> privacyLevel, string reason = null)
Parameters
Type | Name | Description |
---|---|---|
Optional<System.String> | topic | New topic of the stage. |
Optional<StagePrivacyLevel> | privacyLevel | New privacy level of the stage. |
System.String | reason | Audit log reason. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the ManageChannels permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
OpenStageAsync(String, Boolean, StagePrivacyLevel, String)
Opens a stage.
Declaration
public async Task<DiscordStageInstance> OpenStageAsync(string topic, bool sendStartNotification = false, StagePrivacyLevel privacyLevel = StagePrivacyLevel.GuildOnly, string reason = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | topic | Topic of the stage. |
System.Boolean | sendStartNotification | Whether @everyone should be notified. |
StagePrivacyLevel | privacyLevel | Privacy level of the stage (Defaults to GuildOnly. |
System.String | reason | Audit log reason. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<DiscordStageInstance> | Stage instance |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the ManageChannels permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
PermissionsFor(DiscordMember)
Calculates permissions for a given member.
Declaration
public Permissions PermissionsFor(DiscordMember mbr)
Parameters
Type | Name | Description |
---|---|---|
DiscordMember | mbr | Member to calculate permissions for. |
Returns
Type | Description |
---|---|
Permissions | Calculated permissions for a given member. |
PlaceMemberAsync(DiscordMember)
Moves a member to this voice channel.
Declaration
public async Task PlaceMemberAsync(DiscordMember member)
Parameters
Type | Name | Description |
---|---|---|
DiscordMember | member | The member to be moved. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the MoveMembers permission. |
NotFoundException | Thrown when the channel does not exists or if the Member does not exists. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
RefreshPositionsAsync()
Refreshes the positions.
Declaration
public async Task RefreshPositionsAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
RemoveParentAsync(String)
Moves the channel out of a category.
Declaration
public Task RemoveParentAsync(string reason = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | reason | Reason for audit logs. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the ManageChannels permission. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
SendMessageAsync(DiscordEmbed)
Sends a message to this channel.
Declaration
public Task<DiscordMessage> SendMessageAsync(DiscordEmbed embed)
Parameters
Type | Name | Description |
---|---|---|
DiscordEmbed | embed | Embed to attach to the message. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<DiscordMessage> | The sent message. |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the SendMessages permission and SendTtsMessages if TTS is true. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
SendMessageAsync(DiscordMessageBuilder)
Sends a message to this channel.
Declaration
public Task<DiscordMessage> SendMessageAsync(DiscordMessageBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
DiscordMessageBuilder | builder | The builder with all the items to send. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<DiscordMessage> | The sent message. |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the SendMessages permission TTS is true and SendTtsMessages if TTS is true. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
SendMessageAsync(Action<DiscordMessageBuilder>)
Sends a message to this channel.
Declaration
public Task<DiscordMessage> SendMessageAsync(Action<DiscordMessageBuilder> action)
Parameters
Type | Name | Description |
---|---|---|
System.Action<DiscordMessageBuilder> | action | The builder with all the items to send. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<DiscordMessage> | The sent message. |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the SendMessages permission TTS is true and SendTtsMessages if TTS is true. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
SendMessageAsync(String)
Sends a message to this channel.
Declaration
public Task<DiscordMessage> SendMessageAsync(string content)
Parameters
Type | Name | Description |
---|---|---|
System.String | content | Content of the message to send. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<DiscordMessage> | The sent message. |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the SendMessages permission if TTS is true and SendTtsMessages if TTS is true. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
SendMessageAsync(String, DiscordEmbed)
Sends a message to this channel.
Declaration
public Task<DiscordMessage> SendMessageAsync(string content, DiscordEmbed embed)
Parameters
Type | Name | Description |
---|---|---|
System.String | content | Content of the message to send. |
DiscordEmbed | embed | Embed to attach to the message. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<DiscordMessage> | The sent message. |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the SendMessages permission if TTS is true and SendTtsMessages if TTS is true. |
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
ToString()
Returns a string representation of this channel.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | String representation of this channel. |
Overrides
TriggerTypingAsync()
Post a typing indicator.
Declaration
public Task TriggerTypingAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Exceptions
Type | Condition |
---|---|
NotFoundException | Thrown when the channel does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
UpdateCurrentUserVoiceStateAsync(Nullable<Boolean>, Nullable<DateTimeOffset>)
Updates the current user's suppress state in this channel, if stage channel.
Declaration
public async Task UpdateCurrentUserVoiceStateAsync(bool? suppress, DateTimeOffset? requestToSpeakTimestamp = null)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.Boolean> | suppress | Toggles the suppress state. |
System.Nullable<System.DateTimeOffset> | requestToSpeakTimestamp | Sets the time the user requested to speak. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when the channel is not a stage channel. |
Operators
| Improve this Doc View SourceEquality(DiscordChannel, DiscordChannel)
Gets whether the two DiscordChannel objects are equal.
Declaration
public static bool operator ==(DiscordChannel e1, DiscordChannel e2)
Parameters
Type | Name | Description |
---|---|---|
DiscordChannel | e1 | First channel to compare. |
DiscordChannel | e2 | Second channel to compare. |
Returns
Type | Description |
---|---|
System.Boolean | Whether the two channels are equal. |
Inequality(DiscordChannel, DiscordChannel)
Gets whether the two DiscordChannel objects are not equal.
Declaration
public static bool operator !=(DiscordChannel e1, DiscordChannel e2)
Parameters
Type | Name | Description |
---|---|---|
DiscordChannel | e1 | First channel to compare. |
DiscordChannel | e2 | Second channel to compare. |
Returns
Type | Description |
---|---|
System.Boolean | Whether the two channels are not equal. |