From 6457add1b176651ed2c00f81700404003f0b14dc Mon Sep 17 00:00:00 2001 From: drobbins329 Date: Sat, 25 Sep 2021 12:26:46 -0400 Subject: [PATCH] Submitting updates to include new permissions. (#195) * Submitting updates to include new permissions. * Make old permissions obsolete and update tests Co-authored-by: quin lynch --- src/Discord.Net.Core/Discord.Net.Core.xml | 178 +++++++++++++----- .../Entities/Permissions/ChannelPermission.cs | 32 +++- .../Permissions/ChannelPermissions.cs | 143 ++++++++++---- .../Entities/Permissions/GuildPermission.cs | 9 +- .../Entities/Permissions/GuildPermissions.cs | 32 +--- .../Permissions/OverwritePermissions.cs | 72 ++++++- src/Discord.Net.Rest/Discord.Net.Rest.xml | 1 - .../Discord.Net.WebSocket.xml | 4 - .../ChannelPermissionsTests.cs | 4 + test/Discord.Net.Tests.Unit/ColorTests.cs | 2 +- .../GuildPermissionsTests.cs | 4 +- 11 files changed, 351 insertions(+), 130 deletions(-) diff --git a/src/Discord.Net.Core/Discord.Net.Core.xml b/src/Discord.Net.Core/Discord.Net.Core.xml index d72a1cac2..b759c8e13 100644 --- a/src/Discord.Net.Core/Discord.Net.Core.xml +++ b/src/Discord.Net.Core/Discord.Net.Core.xml @@ -8267,7 +8267,7 @@ - Gets a value that indicates whether the current user has reacted to + Gets a value that indicates whether the current user has reacted to this. true if the user has reacted to the message; otherwise false. @@ -8604,7 +8604,12 @@ Allows members to use slash commands in text channels. - + + + Allows members to use slash commands in text channels. + + + Allows for requesting to speak in stage channels. (This permission is under active development and may be changed or removed.) @@ -8624,106 +8629,158 @@ Allows for creating and participating in private threads + + + Allows for creating public threads. + + + + + Allows for creating private threads. + + + + + Allows the usage of custom stickers from other servers. + + + + + Allows for sending messages in threads. + + + + + Allows for launching activities (applications with the EMBEDDED flag) in a voice channel. + + - Gets a blank that grants no permissions. - A structure that does not contain any set permissions. + Gets a blank that grants no permissions. + A structure that does not contain any set permissions. - Gets a that grants all permissions for text channels. + Gets a that grants all permissions for text channels. - Gets a that grants all permissions for voice channels. + Gets a that grants all permissions for voice channels. + + + Gets a that grants all permissions for stage channels. - Gets a that grants all permissions for category channels. + Gets a that grants all permissions for category channels. - Gets a that grants all permissions for direct message channels. + Gets a that grants all permissions for direct message channels. - Gets a that grants all permissions for group channels. + Gets a that grants all permissions for group channels. - Gets a that grants all permissions for a given channel type. + Gets a that grants all permissions for a given channel type. Unknown channel type. - Gets a packed value representing all the permissions in this . + Gets a packed value representing all the permissions in this . - If true, a user may create invites. + If true, a user may create invites. - If true, a user may create, delete and modify this channel. + If true, a user may create, delete and modify this channel. - If true, a user may add reactions. + If true, a user may add reactions. - If true, a user may view channels. + If true, a user may view channels. - If true, a user may send messages. + If true, a user may send messages. - If true, a user may send text-to-speech messages. + If true, a user may send text-to-speech messages. - If true, a user may delete messages. + If true, a user may delete messages. - If true, Discord will auto-embed links sent by this user. + If true, Discord will auto-embed links sent by this user. - If true, a user may send files. + If true, a user may send files. - If true, a user may read previous messages. + If true, a user may read previous messages. - If true, a user may mention @everyone. + If true, a user may mention @everyone. - If true, a user may use custom emoji from other guilds. + If true, a user may use custom emoji from other guilds. - If true, a user may connect to a voice channel. + If true, a user may connect to a voice channel. - If true, a user may speak in a voice channel. + If true, a user may speak in a voice channel. - If true, a user may mute users. + If true, a user may mute users. - If true, a user may deafen users. + If true, a user may deafen users. - If true, a user may move other users between voice channels. + If true, a user may move other users between voice channels. - If true, a user may use voice-activity-detection rather than push-to-talk. + If true, a user may use voice-activity-detection rather than push-to-talk. - If true, a user may use priority speaker in a voice channel. + If true, a user may use priority speaker in a voice channel. - If true, a user may stream video in a voice channel. + If true, a user may stream video in a voice channel. - If true, a user may adjust role permissions. This also implictly grants all other permissions. + If true, a user may adjust role permissions. This also implictly grants all other permissions. - If true, a user may edit the webhooks for this channel. + If true, a user may edit the webhooks for this channel. + + + If true, a user may use application commands in this guild. + + + If true, a user may request to speak in stage channels. + + + If true, a user may manage threads in this guild. + + + If true, a user may create public threads in this guild. + + + If true, a user may create private threads in this guild. + + + If true, a user may use external stickers in this guild. + + + If true, a user may send messages in threads in this guild. + + + If true, a user launch application activites in voice channels in this guild. - Creates a new with the provided packed value. + Creates a new with the provided packed value. - - Creates a new with the provided permissions. + + Creates a new with the provided permissions. - - Creates a new from this one, changing the provided non-null permissions. + + Creates a new from this one, changing the provided non-null permissions. @@ -8950,6 +9007,11 @@ Allows members to use slash commands in text channels. + + + Allows members to use application commands like slash commands and context menus in text channels. + + Allows for requesting to speak in stage channels. (This permission is under active development and may be changed or removed.). @@ -9104,7 +9166,7 @@ If true, a user may edit the emojis and stickers for this guild. - + If true, a user may use slash commands in this guild. @@ -9119,12 +9181,6 @@ If true, a user may create private threads in this guild. - - If true, a user may use public threads in this guild. - - - If true, a user may use private threads in this guild. - If true, a user may use external stickers in this guild. @@ -9140,10 +9196,10 @@ Creates a new with the provided packed value after converting to ulong. - + Creates a new structure with the provided permissions. - + Creates a new from this one, changing the provided non-null permissions. @@ -9284,18 +9340,42 @@ If True, a user may edit the webhooks for this channel. + + If true, a user may use slash commands in this guild. + + + If true, a user may request to speak in stage channels. + + + If true, a user may manage threads in this guild. + + + If true, a user may create public threads in this guild. + + + If true, a user may create private threads in this guild. + + + If true, a user may use external stickers in this guild. + + + If true, a user may send messages in threads in this guild. + + + If true, a user launch application activites in voice channels in this guild. + Creates a new OverwritePermissions with the provided allow and deny packed values. Creates a new OverwritePermissions with the provided allow and deny packed values after converting to ulong. - + Initializes a new struct with the provided permissions. - + Initializes a new from the current one, changing the provided non-null permissions. diff --git a/src/Discord.Net.Core/Entities/Permissions/ChannelPermission.cs b/src/Discord.Net.Core/Entities/Permissions/ChannelPermission.cs index 99e74bd48..d76a579d9 100644 --- a/src/Discord.Net.Core/Entities/Permissions/ChannelPermission.cs +++ b/src/Discord.Net.Core/Entities/Permissions/ChannelPermission.cs @@ -113,12 +113,18 @@ namespace Discord /// /// Allows members to use slash commands in text channels. /// + [Obsolete("UseSlashCommands has been replaced by UseApplicationCommands", true)] UseSlashCommands = 0x00_80_00_00_00, + /// + /// Allows members to use slash commands in text channels. + /// + UseApplicationCommands = 0x00_80_00_00_00, + /// /// Allows for requesting to speak in stage channels. (This permission is under active development and may be changed or removed.) /// - RequesToSpeak = 0x01_00_00_00_00, + RequestToSpeak = 0x01_00_00_00_00, /// /// Allows for deleting and archiving threads, and viewing all private threads @@ -128,12 +134,34 @@ namespace Discord /// /// Allows for creating and participating in threads /// - UsePublicThreads = 0x08_00_00_00_00, + [Obsolete("UsePublicThreads has been replaced by CreatePublicThreads and SendMessagesInThreads", true)] + UsePublicThreads = 0x08_00_00_00_00, /// /// Allows for creating and participating in private threads /// + [Obsolete("UsePrivateThreads has been replaced by CreatePrivateThreads and SendMessagesInThreads", true)] UsePrivateThreads = 0x10_00_00_00_00, + /// + /// Allows for creating public threads. + /// + CreatePublicThreads = 0x08_00_00_00_00, + /// + /// Allows for creating private threads. + /// + CreatePrivateThreads = 0x10_00_00_00_00, + /// + /// Allows the usage of custom stickers from other servers. + /// + UseExternalStickers = 0x20_00_00_00_00, + /// + /// Allows for sending messages in threads. + /// + SendMessagesInThreads = 0x40_00_00_00_00, + /// + /// Allows for launching activities (applications with the EMBEDDED flag) in a voice channel. + /// + StartEmbeddedActivities = 0x80_00_00_00_00 } } diff --git a/src/Discord.Net.Core/Entities/Permissions/ChannelPermissions.cs b/src/Discord.Net.Core/Entities/Permissions/ChannelPermissions.cs index 287e69783..11130731e 100644 --- a/src/Discord.Net.Core/Entities/Permissions/ChannelPermissions.cs +++ b/src/Discord.Net.Core/Entities/Permissions/ChannelPermissions.cs @@ -7,26 +7,29 @@ namespace Discord [DebuggerDisplay("{DebuggerDisplay,nq}")] public struct ChannelPermissions { - /// Gets a blank that grants no permissions. - /// A structure that does not contain any set permissions. + /// Gets a blank that grants no permissions. + /// A structure that does not contain any set permissions. public static readonly ChannelPermissions None = new ChannelPermissions(); - /// Gets a that grants all permissions for text channels. - public static readonly ChannelPermissions Text = new ChannelPermissions(0b01100_0000000_1111111110001_010001); - /// Gets a that grants all permissions for voice channels. - public static readonly ChannelPermissions Voice = new ChannelPermissions(0b00100_1111110_0000000011100_010001); - /// Gets a that grants all permissions for category channels. + /// Gets a that grants all permissions for text channels. + public static readonly ChannelPermissions Text = new ChannelPermissions(0b0_11111_0101100_0000000_1111111110001_010001); + /// Gets a that grants all permissions for voice channels. + public static readonly ChannelPermissions Voice = new ChannelPermissions(0b1_00000_0000100_1111110_0000000011100_010001); + /// Gets a that grants all permissions for stage channels. + public static readonly ChannelPermissions Stage = new ChannelPermissions(0b0_00000_1000100_0111010_0000000010000_010001); + /// Gets a that grants all permissions for category channels. public static readonly ChannelPermissions Category = new ChannelPermissions(0b01100_1111110_1111111110001_010001); - /// Gets a that grants all permissions for direct message channels. + /// Gets a that grants all permissions for direct message channels. public static readonly ChannelPermissions DM = new ChannelPermissions(0b00000_1000110_1011100110001_000000); - /// Gets a that grants all permissions for group channels. + /// Gets a that grants all permissions for group channels. public static readonly ChannelPermissions Group = new ChannelPermissions(0b00000_1000110_0001101100000_000000); - /// Gets a that grants all permissions for a given channel type. + /// Gets a that grants all permissions for a given channel type. /// Unknown channel type. public static ChannelPermissions All(IChannel channel) { return channel switch { ITextChannel _ => Text, + IStageChannel _ => Stage, IVoiceChannel _ => Voice, ICategoryChannel _ => Category, IDMChannel _ => DM, @@ -35,59 +38,75 @@ namespace Discord }; } - /// Gets a packed value representing all the permissions in this . + /// Gets a packed value representing all the permissions in this . public ulong RawValue { get; } - /// If true, a user may create invites. + /// If true, a user may create invites. public bool CreateInstantInvite => Permissions.GetValue(RawValue, ChannelPermission.CreateInstantInvite); - /// If true, a user may create, delete and modify this channel. + /// If true, a user may create, delete and modify this channel. public bool ManageChannel => Permissions.GetValue(RawValue, ChannelPermission.ManageChannels); - /// If true, a user may add reactions. + /// If true, a user may add reactions. public bool AddReactions => Permissions.GetValue(RawValue, ChannelPermission.AddReactions); - /// If true, a user may view channels. + /// If true, a user may view channels. public bool ViewChannel => Permissions.GetValue(RawValue, ChannelPermission.ViewChannel); - /// If true, a user may send messages. + /// If true, a user may send messages. public bool SendMessages => Permissions.GetValue(RawValue, ChannelPermission.SendMessages); - /// If true, a user may send text-to-speech messages. + /// If true, a user may send text-to-speech messages. public bool SendTTSMessages => Permissions.GetValue(RawValue, ChannelPermission.SendTTSMessages); - /// If true, a user may delete messages. + /// If true, a user may delete messages. public bool ManageMessages => Permissions.GetValue(RawValue, ChannelPermission.ManageMessages); - /// If true, Discord will auto-embed links sent by this user. + /// If true, Discord will auto-embed links sent by this user. public bool EmbedLinks => Permissions.GetValue(RawValue, ChannelPermission.EmbedLinks); - /// If true, a user may send files. + /// If true, a user may send files. public bool AttachFiles => Permissions.GetValue(RawValue, ChannelPermission.AttachFiles); - /// If true, a user may read previous messages. + /// If true, a user may read previous messages. public bool ReadMessageHistory => Permissions.GetValue(RawValue, ChannelPermission.ReadMessageHistory); - /// If true, a user may mention @everyone. + /// If true, a user may mention @everyone. public bool MentionEveryone => Permissions.GetValue(RawValue, ChannelPermission.MentionEveryone); - /// If true, a user may use custom emoji from other guilds. + /// If true, a user may use custom emoji from other guilds. public bool UseExternalEmojis => Permissions.GetValue(RawValue, ChannelPermission.UseExternalEmojis); - /// If true, a user may connect to a voice channel. + /// If true, a user may connect to a voice channel. public bool Connect => Permissions.GetValue(RawValue, ChannelPermission.Connect); - /// If true, a user may speak in a voice channel. + /// If true, a user may speak in a voice channel. public bool Speak => Permissions.GetValue(RawValue, ChannelPermission.Speak); - /// If true, a user may mute users. + /// If true, a user may mute users. public bool MuteMembers => Permissions.GetValue(RawValue, ChannelPermission.MuteMembers); - /// If true, a user may deafen users. + /// If true, a user may deafen users. public bool DeafenMembers => Permissions.GetValue(RawValue, ChannelPermission.DeafenMembers); - /// If true, a user may move other users between voice channels. + /// If true, a user may move other users between voice channels. public bool MoveMembers => Permissions.GetValue(RawValue, ChannelPermission.MoveMembers); - /// If true, a user may use voice-activity-detection rather than push-to-talk. + /// If true, a user may use voice-activity-detection rather than push-to-talk. public bool UseVAD => Permissions.GetValue(RawValue, ChannelPermission.UseVAD); - /// If true, a user may use priority speaker in a voice channel. + /// If true, a user may use priority speaker in a voice channel. public bool PrioritySpeaker => Permissions.GetValue(RawValue, ChannelPermission.PrioritySpeaker); - /// If true, a user may stream video in a voice channel. + /// If true, a user may stream video in a voice channel. public bool Stream => Permissions.GetValue(RawValue, ChannelPermission.Stream); - /// If true, a user may adjust role permissions. This also implictly grants all other permissions. + /// If true, a user may adjust role permissions. This also implictly grants all other permissions. public bool ManageRoles => Permissions.GetValue(RawValue, ChannelPermission.ManageRoles); - /// If true, a user may edit the webhooks for this channel. + /// If true, a user may edit the webhooks for this channel. public bool ManageWebhooks => Permissions.GetValue(RawValue, ChannelPermission.ManageWebhooks); + /// If true, a user may use application commands in this guild. + public bool UseApplicationCommands => Permissions.GetValue(RawValue, ChannelPermission.UseApplicationCommands); + /// If true, a user may request to speak in stage channels. + public bool RequestToSpeak => Permissions.GetValue(RawValue, ChannelPermission.RequestToSpeak); + /// If true, a user may manage threads in this guild. + public bool ManageThreads => Permissions.GetValue(RawValue, ChannelPermission.ManageThreads); + /// If true, a user may create public threads in this guild. + public bool CreatePublicThreads => Permissions.GetValue(RawValue, ChannelPermission.CreatePublicThreads); + /// If true, a user may create private threads in this guild. + public bool CreatePrivateThreads => Permissions.GetValue(RawValue, ChannelPermission.CreatePrivateThreads); + /// If true, a user may use external stickers in this guild. + public bool UseExternalStickers => Permissions.GetValue(RawValue, ChannelPermission.UseExternalStickers); + /// If true, a user may send messages in threads in this guild. + public bool SendMessagesInThreads => Permissions.GetValue(RawValue, ChannelPermission.SendMessagesInThreads); + /// If true, a user launch application activites in voice channels in this guild. + public bool StartEmbeddedActivities => Permissions.GetValue(RawValue, ChannelPermission.StartEmbeddedActivities); - /// Creates a new with the provided packed value. + /// Creates a new with the provided packed value. public ChannelPermissions(ulong rawValue) { RawValue = rawValue; } private ChannelPermissions(ulong initialValue, @@ -112,7 +131,15 @@ namespace Discord bool? prioritySpeaker = null, bool? stream = null, bool? manageRoles = null, - bool? manageWebhooks = null) + bool? manageWebhooks = null, + bool? useApplicationCommands = null, + bool? requestToSpeak = null, + bool? manageThreads = null, + bool? createPublicThreads = null, + bool? createPrivateThreads = null, + bool? useExternalStickers = null, + bool? sendMessagesInThreads = null, + bool? startEmbeddedActivities = null) { ulong value = initialValue; @@ -138,11 +165,19 @@ namespace Discord Permissions.SetValue(ref value, stream, ChannelPermission.Stream); Permissions.SetValue(ref value, manageRoles, ChannelPermission.ManageRoles); Permissions.SetValue(ref value, manageWebhooks, ChannelPermission.ManageWebhooks); + Permissions.SetValue(ref value, useApplicationCommands, ChannelPermission.UseApplicationCommands); + Permissions.SetValue(ref value, requestToSpeak, ChannelPermission.RequestToSpeak); + Permissions.SetValue(ref value, manageThreads, ChannelPermission.ManageThreads); + Permissions.SetValue(ref value, createPublicThreads, ChannelPermission.CreatePublicThreads); + Permissions.SetValue(ref value, createPrivateThreads, ChannelPermission.CreatePrivateThreads); + Permissions.SetValue(ref value, useExternalStickers, ChannelPermission.UseExternalStickers); + Permissions.SetValue(ref value, sendMessagesInThreads, ChannelPermission.SendMessagesInThreads); + Permissions.SetValue(ref value, startEmbeddedActivities, ChannelPermission.StartEmbeddedActivities); RawValue = value; } - /// Creates a new with the provided permissions. + /// Creates a new with the provided permissions. public ChannelPermissions( bool createInstantInvite = false, bool manageChannel = false, @@ -165,13 +200,23 @@ namespace Discord bool prioritySpeaker = false, bool stream = false, bool manageRoles = false, - bool manageWebhooks = false) + bool manageWebhooks = false, + bool useApplicationCommands = false, + bool requestToSpeak = false, + bool manageThreads = false, + bool createPublicThreads = false, + bool createPrivateThreads = false, + bool useExternalStickers = false, + bool sendMessagesInThreads = false, + bool startEmbeddedActivities = false) : this(0, createInstantInvite, manageChannel, addReactions, viewChannel, sendMessages, sendTTSMessages, manageMessages, embedLinks, attachFiles, readMessageHistory, mentionEveryone, useExternalEmojis, connect, - speak, muteMembers, deafenMembers, moveMembers, useVoiceActivation, prioritySpeaker, stream, manageRoles, manageWebhooks) + speak, muteMembers, deafenMembers, moveMembers, useVoiceActivation, prioritySpeaker, stream, manageRoles, manageWebhooks, + useApplicationCommands, requestToSpeak, manageThreads, createPublicThreads, createPrivateThreads, useExternalStickers, sendMessagesInThreads, + startEmbeddedActivities) { } - /// Creates a new from this one, changing the provided non-null permissions. + /// Creates a new from this one, changing the provided non-null permissions. public ChannelPermissions Modify( bool? createInstantInvite = null, bool? manageChannel = null, @@ -194,7 +239,15 @@ namespace Discord bool? prioritySpeaker = null, bool? stream = null, bool? manageRoles = null, - bool? manageWebhooks = null) + bool? manageWebhooks = null, + bool? useApplicationCommands = null, + bool? requestToSpeak = null, + bool? manageThreads = null, + bool? createPublicThreads = null, + bool? createPrivateThreads = null, + bool? useExternalStickers = null, + bool? sendMessagesInThreads = null, + bool? startEmbeddedActivities = null) => new ChannelPermissions(RawValue, createInstantInvite, manageChannel, @@ -217,7 +270,15 @@ namespace Discord prioritySpeaker, stream, manageRoles, - manageWebhooks); + manageWebhooks, + useApplicationCommands, + requestToSpeak, + manageThreads, + createPublicThreads, + createPrivateThreads, + useExternalStickers, + sendMessagesInThreads, + startEmbeddedActivities); public bool Has(ChannelPermission permission) => Permissions.GetValue(RawValue, permission); diff --git a/src/Discord.Net.Core/Entities/Permissions/GuildPermission.cs b/src/Discord.Net.Core/Entities/Permissions/GuildPermission.cs index 53b666b1a..746981c6e 100644 --- a/src/Discord.Net.Core/Entities/Permissions/GuildPermission.cs +++ b/src/Discord.Net.Core/Entities/Permissions/GuildPermission.cs @@ -178,8 +178,13 @@ namespace Discord /// /// Allows members to use slash commands in text channels. /// + [Obsolete("UseSlashCommands has been replaced by UseApplicationCommands", true)] UseSlashCommands = 0x80_00_00_00, /// + /// Allows members to use application commands like slash commands and context menus in text channels. + /// + UseApplicationCommands = 0x80_00_00_00, + /// /// Allows for requesting to speak in stage channels. (This permission is under active development and may be changed or removed.). /// RequestToSpeak = 0x01_00_00_00_00, @@ -202,12 +207,12 @@ namespace Discord /// /// Allows for creating public threads. /// - [Obsolete("UsePublicThreads has been replaced by CreatePublicThreads and SendMessagesInThreads")] + [Obsolete("UsePublicThreads has been replaced by CreatePublicThreads and SendMessagesInThreads", true)] UsePublicThreads = 0x08_00_00_00_00, /// /// Allows for creating private threads. /// - [Obsolete("UsePrivateThreads has been replaced by CreatePrivateThreads and SendMessagesInThreads")] + [Obsolete("UsePrivateThreads has been replaced by CreatePrivateThreads and SendMessagesInThreads", true)] UsePrivateThreads = 0x10_00_00_00_00, /// /// Allows the usage of custom stickers from other servers. diff --git a/src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs b/src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs index f909b6381..8924936a0 100644 --- a/src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs +++ b/src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs @@ -10,9 +10,9 @@ namespace Discord /// Gets a blank that grants no permissions. public static readonly GuildPermissions None = new GuildPermissions(); /// Gets a that grants all guild permissions for webhook users. - public static readonly GuildPermissions Webhook = new GuildPermissions(0b00000_0000000_0001101100000_000000); + public static readonly GuildPermissions Webhook = new GuildPermissions(0b0_00000_0000000_0000000_0001101100000_000000); /// Gets a that grants all guild permissions. - public static readonly GuildPermissions All = new GuildPermissions(0b1111111111_11111_1111111_1111111111111_11111); + public static readonly GuildPermissions All = new GuildPermissions(0b1_11111_1111111_1111111_1111111111111_111111); /// Gets a packed value representing all the permissions in this . public ulong RawValue { get; } @@ -84,7 +84,7 @@ namespace Discord /// If true, a user may edit the emojis and stickers for this guild. public bool ManageEmojisAndStickers => Permissions.GetValue(RawValue, GuildPermission.ManageEmojisAndStickers); /// If true, a user may use slash commands in this guild. - public bool UseSlashCommands => Permissions.GetValue(RawValue, GuildPermission.UseSlashCommands); + public bool UseApplicationCommands => Permissions.GetValue(RawValue, GuildPermission.UseApplicationCommands); /// If true, a user may request to speak in stage channels. public bool RequestToSpeak => Permissions.GetValue(RawValue, GuildPermission.RequestToSpeak); /// If true, a user may manage threads in this guild. @@ -93,10 +93,6 @@ namespace Discord public bool CreatePublicThreads => Permissions.GetValue(RawValue, GuildPermission.CreatePublicThreads); /// If true, a user may create private threads in this guild. public bool CreatePrivateThreads => Permissions.GetValue(RawValue, GuildPermission.CreatePrivateThreads); - /// If true, a user may use public threads in this guild. - public bool UsePublicThreads => Permissions.GetValue(RawValue, GuildPermission.UsePublicThreads); - /// If true, a user may use private threads in this guild. - public bool UsePrivateThreads => Permissions.GetValue(RawValue, GuildPermission.UsePrivateThreads); /// If true, a user may use external stickers in this guild. public bool UseExternalStickers => Permissions.GetValue(RawValue, GuildPermission.UseExternalStickers); /// If true, a user may send messages in threads in this guild. @@ -142,13 +138,11 @@ namespace Discord bool? manageRoles = null, bool? manageWebhooks = null, bool? manageEmojisAndStickers = null, - bool? useSlashCommands = null, + bool? useApplicationCommands = null, bool? requestToSpeak = null, bool? manageThreads = null, bool? createPublicThreads = null, bool? createPrivateThreads = null, - bool? usePublicThreads = null, - bool? usePrivateThreads = null, bool? useExternalStickers = null, bool? sendMessagesInThreads = null, bool? startEmbeddedActivities = null) @@ -186,13 +180,11 @@ namespace Discord Permissions.SetValue(ref value, manageRoles, GuildPermission.ManageRoles); Permissions.SetValue(ref value, manageWebhooks, GuildPermission.ManageWebhooks); Permissions.SetValue(ref value, manageEmojisAndStickers, GuildPermission.ManageEmojisAndStickers); - Permissions.SetValue(ref value, useSlashCommands, GuildPermission.UseSlashCommands); + Permissions.SetValue(ref value, useApplicationCommands, GuildPermission.UseApplicationCommands); Permissions.SetValue(ref value, requestToSpeak, GuildPermission.RequestToSpeak); Permissions.SetValue(ref value, manageThreads, GuildPermission.ManageThreads); Permissions.SetValue(ref value, createPublicThreads, GuildPermission.CreatePublicThreads); Permissions.SetValue(ref value, createPrivateThreads, GuildPermission.CreatePrivateThreads); - Permissions.SetValue(ref value, usePublicThreads, GuildPermission.UsePublicThreads); - Permissions.SetValue(ref value, usePrivateThreads, GuildPermission.UsePrivateThreads); Permissions.SetValue(ref value, useExternalStickers, GuildPermission.UseExternalStickers); Permissions.SetValue(ref value, sendMessagesInThreads, GuildPermission.SendMessagesInThreads); Permissions.SetValue(ref value, startEmbeddedActivities, GuildPermission.StartEmbeddedActivities); @@ -233,13 +225,11 @@ namespace Discord bool manageRoles = false, bool manageWebhooks = false, bool manageEmojisAndStickers = false, - bool useSlashCommands = false, + bool useApplicationCommands = false, bool requestToSpeak = false, bool manageThreads = false, bool createPublicThreads = false, bool createPrivateThreads = false, - bool usePublicThreads = false, - bool usePrivateThreads = false, bool useExternalStickers = false, bool sendMessagesInThreads = false, bool startEmbeddedActivities = false) @@ -275,13 +265,11 @@ namespace Discord manageNicknames: manageNicknames, manageWebhooks: manageWebhooks, manageEmojisAndStickers: manageEmojisAndStickers, - useSlashCommands: useSlashCommands, + useApplicationCommands: useApplicationCommands, requestToSpeak: requestToSpeak, manageThreads: manageThreads, createPublicThreads: createPublicThreads, createPrivateThreads: createPrivateThreads, - usePublicThreads: usePublicThreads, - usePrivateThreads: usePrivateThreads, useExternalStickers: useExternalStickers, sendMessagesInThreads: sendMessagesInThreads, startEmbeddedActivities: startEmbeddedActivities) @@ -320,13 +308,11 @@ namespace Discord bool? manageRoles = null, bool? manageWebhooks = null, bool? manageEmojisAndStickers = null, - bool? useSlashCommands = null, + bool? useApplicationCommands = null, bool? requestToSpeak = null, bool? manageThreads = null, bool? createPublicThreads = null, bool? createPrivateThreads = null, - bool? usePublicThreads = null, - bool? usePrivateThreads = null, bool? useExternalStickers = null, bool? sendMessagesInThreads = null, bool? startEmbeddedActivities = null) @@ -334,7 +320,7 @@ namespace Discord viewAuditLog, viewGuildInsights, viewChannel, sendMessages, sendTTSMessages, manageMessages, embedLinks, attachFiles, readMessageHistory, mentionEveryone, useExternalEmojis, connect, speak, muteMembers, deafenMembers, moveMembers, useVoiceActivation, prioritySpeaker, stream, changeNickname, manageNicknames, manageRoles, manageWebhooks, manageEmojisAndStickers, - useSlashCommands, requestToSpeak, manageThreads, createPublicThreads, createPrivateThreads, usePublicThreads, usePrivateThreads, useExternalStickers, sendMessagesInThreads, + useApplicationCommands, requestToSpeak, manageThreads, createPublicThreads, createPrivateThreads, useExternalStickers, sendMessagesInThreads, startEmbeddedActivities); /// diff --git a/src/Discord.Net.Core/Entities/Permissions/OverwritePermissions.cs b/src/Discord.Net.Core/Entities/Permissions/OverwritePermissions.cs index 4f144c74b..cff938465 100644 --- a/src/Discord.Net.Core/Entities/Permissions/OverwritePermissions.cs +++ b/src/Discord.Net.Core/Entities/Permissions/OverwritePermissions.cs @@ -1,3 +1,4 @@ +using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Diagnostics; @@ -82,6 +83,22 @@ namespace Discord public PermValue ManageRoles => Permissions.GetValue(AllowValue, DenyValue, ChannelPermission.ManageRoles); /// If True, a user may edit the webhooks for this channel. public PermValue ManageWebhooks => Permissions.GetValue(AllowValue, DenyValue, ChannelPermission.ManageWebhooks); + /// If true, a user may use slash commands in this guild. + public PermValue UseApplicationCommands => Permissions.GetValue(AllowValue, DenyValue, ChannelPermission.UseApplicationCommands); + /// If true, a user may request to speak in stage channels. + public PermValue RequestToSpeak => Permissions.GetValue(AllowValue, DenyValue, ChannelPermission.RequestToSpeak); + /// If true, a user may manage threads in this guild. + public PermValue ManageThreads => Permissions.GetValue(AllowValue, DenyValue, ChannelPermission.ManageThreads); + /// If true, a user may create public threads in this guild. + public PermValue CreatePublicThreads => Permissions.GetValue(AllowValue, DenyValue, ChannelPermission.CreatePublicThreads); + /// If true, a user may create private threads in this guild. + public PermValue CreatePrivateThreads => Permissions.GetValue(AllowValue, DenyValue, ChannelPermission.CreatePrivateThreads); + /// If true, a user may use external stickers in this guild. + public PermValue UseExternalStickers => Permissions.GetValue(AllowValue, DenyValue, ChannelPermission.UseExternalStickers); + /// If true, a user may send messages in threads in this guild. + public PermValue SendMessagesInThreads => Permissions.GetValue(AllowValue, DenyValue, ChannelPermission.SendMessagesInThreads); + /// If true, a user launch application activites in voice channels in this guild. + public PermValue StartEmbeddedActivities => Permissions.GetValue(AllowValue, DenyValue, ChannelPermission.StartEmbeddedActivities); /// Creates a new OverwritePermissions with the provided allow and deny packed values. public OverwritePermissions(ulong allowValue, ulong denyValue) @@ -119,7 +136,18 @@ namespace Discord PermValue? manageRoles = null, PermValue? manageWebhooks = null, PermValue? prioritySpeaker = null, - PermValue? stream = null) + PermValue? stream = null, + PermValue? useSlashCommands = null, + PermValue? useApplicationCommands = null, + PermValue? requestToSpeak = null, + PermValue? manageThreads = null, + PermValue? createPublicThreads = null, + PermValue? createPrivateThreads = null, + PermValue? usePublicThreads = null, + PermValue? usePrivateThreads = null, + PermValue? useExternalStickers = null, + PermValue? sendMessagesInThreads = null, + PermValue? startEmbeddedActivities = null) { Permissions.SetValue(ref allowValue, ref denyValue, createInstantInvite, ChannelPermission.CreateInstantInvite); Permissions.SetValue(ref allowValue, ref denyValue, manageChannel, ChannelPermission.ManageChannels); @@ -143,6 +171,14 @@ namespace Discord Permissions.SetValue(ref allowValue, ref denyValue, stream, ChannelPermission.Stream); Permissions.SetValue(ref allowValue, ref denyValue, manageRoles, ChannelPermission.ManageRoles); Permissions.SetValue(ref allowValue, ref denyValue, manageWebhooks, ChannelPermission.ManageWebhooks); + Permissions.SetValue(ref allowValue, ref denyValue, useApplicationCommands, ChannelPermission.UseApplicationCommands); + Permissions.SetValue(ref allowValue, ref denyValue, requestToSpeak, ChannelPermission.RequestToSpeak); + Permissions.SetValue(ref allowValue, ref denyValue, manageThreads, ChannelPermission.ManageThreads); + Permissions.SetValue(ref allowValue, ref denyValue, createPublicThreads, ChannelPermission.CreatePublicThreads); + Permissions.SetValue(ref allowValue, ref denyValue, createPrivateThreads, ChannelPermission.CreatePrivateThreads); + Permissions.SetValue(ref allowValue, ref denyValue, useExternalStickers, ChannelPermission.UseExternalStickers); + Permissions.SetValue(ref allowValue, ref denyValue, sendMessagesInThreads, ChannelPermission.SendMessagesInThreads); + Permissions.SetValue(ref allowValue, ref denyValue, startEmbeddedActivities, ChannelPermission.StartEmbeddedActivities); AllowValue = allowValue; DenyValue = denyValue; @@ -173,10 +209,23 @@ namespace Discord PermValue manageRoles = PermValue.Inherit, PermValue manageWebhooks = PermValue.Inherit, PermValue prioritySpeaker = PermValue.Inherit, - PermValue stream = PermValue.Inherit) + PermValue stream = PermValue.Inherit, + PermValue useSlashCommands = PermValue.Inherit, + PermValue useApplicationCommands = PermValue.Inherit, + PermValue requestToSpeak = PermValue.Inherit, + PermValue manageThreads = PermValue.Inherit, + PermValue createPublicThreads = PermValue.Inherit, + PermValue createPrivateThreads = PermValue.Inherit, + PermValue usePublicThreads = PermValue.Inherit, + PermValue usePrivateThreads = PermValue.Inherit, + PermValue useExternalStickers = PermValue.Inherit, + PermValue sendMessagesInThreads = PermValue.Inherit, + PermValue startEmbeddedActivities = PermValue.Inherit) : this(0, 0, createInstantInvite, manageChannel, addReactions, viewChannel, sendMessages, sendTTSMessages, manageMessages, embedLinks, attachFiles, readMessageHistory, mentionEveryone, useExternalEmojis, connect, speak, muteMembers, deafenMembers, - moveMembers, useVoiceActivation, manageRoles, manageWebhooks, prioritySpeaker, stream) { } + moveMembers, useVoiceActivation, manageRoles, manageWebhooks, prioritySpeaker, stream, useSlashCommands, useApplicationCommands, + requestToSpeak, manageThreads, createPublicThreads, createPrivateThreads, usePublicThreads, usePrivateThreads, useExternalStickers, + sendMessagesInThreads, startEmbeddedActivities) { } /// /// Initializes a new from the current one, changing the provided @@ -204,10 +253,23 @@ namespace Discord PermValue? manageRoles = null, PermValue? manageWebhooks = null, PermValue? prioritySpeaker = null, - PermValue? stream = null) + PermValue? stream = null, + PermValue? useSlashCommands = null, + PermValue? useApplicationCommands = null, + PermValue? requestToSpeak = null, + PermValue? manageThreads = null, + PermValue? createPublicThreads = null, + PermValue? createPrivateThreads = null, + PermValue? usePublicThreads = null, + PermValue? usePrivateThreads = null, + PermValue? useExternalStickers = null, + PermValue? sendMessagesInThreads = null, + PermValue? startEmbeddedActivities = null) => new OverwritePermissions(AllowValue, DenyValue, createInstantInvite, manageChannel, addReactions, viewChannel, sendMessages, sendTTSMessages, manageMessages, embedLinks, attachFiles, readMessageHistory, mentionEveryone, useExternalEmojis, connect, speak, muteMembers, deafenMembers, - moveMembers, useVoiceActivation, manageRoles, manageWebhooks, prioritySpeaker, stream); + moveMembers, useVoiceActivation, manageRoles, manageWebhooks, prioritySpeaker, stream, useSlashCommands, useApplicationCommands, + requestToSpeak, manageThreads, createPublicThreads, createPrivateThreads, usePublicThreads, usePrivateThreads, useExternalStickers, + sendMessagesInThreads, startEmbeddedActivities); /// /// Creates a of all the values that are allowed. diff --git a/src/Discord.Net.Rest/Discord.Net.Rest.xml b/src/Discord.Net.Rest/Discord.Net.Rest.xml index af46d06ad..f6ce59739 100644 --- a/src/Discord.Net.Rest/Discord.Net.Rest.xml +++ b/src/Discord.Net.Rest/Discord.Net.Rest.xml @@ -3243,7 +3243,6 @@ Gets a collection of all stage channels in this guild. - The that determines whether the object should be fetched from cache. The options to be used when sending the request. A task that represents the asynchronous get operation. The task result contains a read-only collection of diff --git a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml index c194d00ef..b2b80b2eb 100644 --- a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml +++ b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml @@ -4286,10 +4286,6 @@ Responds to an Interaction with type . - - If you have set to , You should use - instead. - The text of the message to be sent. A array of embeds to send with this response. Max 10. diff --git a/test/Discord.Net.Tests.Unit/ChannelPermissionsTests.cs b/test/Discord.Net.Tests.Unit/ChannelPermissionsTests.cs index a3566590a..2cab8fa21 100644 --- a/test/Discord.Net.Tests.Unit/ChannelPermissionsTests.cs +++ b/test/Discord.Net.Tests.Unit/ChannelPermissionsTests.cs @@ -85,6 +85,10 @@ namespace Discord AssertFlag(() => new ChannelPermissions(stream: true), ChannelPermission.Stream); AssertFlag(() => new ChannelPermissions(manageRoles: true), ChannelPermission.ManageRoles); AssertFlag(() => new ChannelPermissions(manageWebhooks: true), ChannelPermission.ManageWebhooks); + AssertFlag(() => new ChannelPermissions(useApplicationCommands: true), ChannelPermission.UseApplicationCommands); + AssertFlag(() => new ChannelPermissions(createPrivateThreads: true), ChannelPermission.CreatePrivateThreads); + AssertFlag(() => new ChannelPermissions(createPublicThreads: true), ChannelPermission.CreatePublicThreads); + AssertFlag(() => new ChannelPermissions(sendMessagesInThreads: true), ChannelPermission.SendMessagesInThreads); } /// diff --git a/test/Discord.Net.Tests.Unit/ColorTests.cs b/test/Discord.Net.Tests.Unit/ColorTests.cs index 87c76e4e2..48a6041e5 100644 --- a/test/Discord.Net.Tests.Unit/ColorTests.cs +++ b/test/Discord.Net.Tests.Unit/ColorTests.cs @@ -15,7 +15,7 @@ namespace Discord { Assert.Equal(0u, new Color().RawValue); Assert.Equal(uint.MinValue, new Color(uint.MinValue).RawValue); - Assert.Equal(uint.MaxValue, new Color(uint.MaxValue).RawValue); + Assert.Throws(() => new Color(uint.MaxValue)); } [Fact] public void Color_Default() diff --git a/test/Discord.Net.Tests.Unit/GuildPermissionsTests.cs b/test/Discord.Net.Tests.Unit/GuildPermissionsTests.cs index 68a685fdb..00ca05504 100644 --- a/test/Discord.Net.Tests.Unit/GuildPermissionsTests.cs +++ b/test/Discord.Net.Tests.Unit/GuildPermissionsTests.cs @@ -92,7 +92,7 @@ namespace Discord AssertFlag(() => new GuildPermissions(manageRoles: true), GuildPermission.ManageRoles); AssertFlag(() => new GuildPermissions(manageWebhooks: true), GuildPermission.ManageWebhooks); AssertFlag(() => new GuildPermissions(manageEmojisAndStickers: true), GuildPermission.ManageEmojisAndStickers); - AssertFlag(() => new GuildPermissions(useSlashCommands: true), GuildPermission.UseSlashCommands); + AssertFlag(() => new GuildPermissions(useApplicationCommands: true), GuildPermission.UseApplicationCommands); AssertFlag(() => new GuildPermissions(requestToSpeak: true), GuildPermission.RequestToSpeak); AssertFlag(() => new GuildPermissions(manageThreads: true), GuildPermission.ManageThreads); AssertFlag(() => new GuildPermissions(createPublicThreads: true), GuildPermission.CreatePublicThreads); @@ -168,7 +168,7 @@ namespace Discord AssertUtil(GuildPermission.ManageRoles, x => x.ManageRoles, (p, enable) => p.Modify(manageRoles: enable)); AssertUtil(GuildPermission.ManageWebhooks, x => x.ManageWebhooks, (p, enable) => p.Modify(manageWebhooks: enable)); AssertUtil(GuildPermission.ManageEmojisAndStickers, x => x.ManageEmojisAndStickers, (p, enable) => p.Modify(manageEmojisAndStickers: enable)); - AssertUtil(GuildPermission.UseSlashCommands, x => x.UseSlashCommands, (p, enable) => p.Modify(useSlashCommands: enable)); + AssertUtil(GuildPermission.UseApplicationCommands, x => x.UseApplicationCommands, (p, enable) => p.Modify(useApplicationCommands: enable)); AssertUtil(GuildPermission.RequestToSpeak, x => x.RequestToSpeak, (p, enable) => p.Modify(requestToSpeak: enable)); AssertUtil(GuildPermission.ManageThreads, x => x.ManageThreads, (p, enable) => p.Modify(manageThreads: enable)); AssertUtil(GuildPermission.CreatePublicThreads, x => x.CreatePublicThreads, (p, enable) => p.Modify(createPublicThreads: enable));