diff --git a/src/Discord.Net.Core/Entities/Permissions/ChannelPermission.cs b/src/Discord.Net.Core/Entities/Permissions/ChannelPermission.cs index 8674399e..21026b99 100644 --- a/src/Discord.Net.Core/Entities/Permissions/ChannelPermission.cs +++ b/src/Discord.Net.Core/Entities/Permissions/ChannelPermission.cs @@ -10,141 +10,172 @@ namespace Discord /// /// Allows creation of instant invites. /// - CreateInstantInvite = 0x00_00_00_00_01, + CreateInstantInvite = 1L << 0, + /// /// Allows management and editing of channels. /// - ManageChannels = 0x00_00_00_00_10, + ManageChannels = 1L << 4, // Text /// /// Allows for the addition of reactions to messages. /// - AddReactions = 0x00_00_00_00_40, + AddReactions = 1L << 6, + /// /// Allows guild members to view a channel, which includes reading messages in text channels. /// - ViewChannel = 0x00_00_00_04_00, + ViewChannel = 1L << 10, + /// /// Allows for sending messages in a channel. /// - SendMessages = 0x00_00_00_08_00, + SendMessages = 1L << 11, + /// /// Allows for sending of text-to-speech messages. /// - SendTTSMessages = 0x00_00_00_10_00, + SendTTSMessages = 1L << 12, + /// /// Allows for deletion of other users messages. /// - ManageMessages = 0x00_00_00_20_00, + ManageMessages = 1L << 13, + /// /// Allows links sent by users with this permission will be auto-embedded. /// - EmbedLinks = 0x00_00_00_40_00, + EmbedLinks = 1L << 14, + /// /// Allows for uploading images and files. /// - AttachFiles = 0x00_00_00_80_00, + AttachFiles = 1L << 15, + /// /// Allows for reading of message history. /// - ReadMessageHistory = 0x00_00_01_00_00, + ReadMessageHistory = 1L << 16, + /// /// Allows for using the @everyone tag to notify all users in a channel, and the @here tag to notify all /// online users in a channel. /// - MentionEveryone = 0x00_00_02_00_00, + MentionEveryone = 1L << 17, + /// /// Allows the usage of custom emojis from other servers. /// - UseExternalEmojis = 0x00_00_04_00_00, + UseExternalEmojis = 1L << 18, + // Voice + /// /// Allows for joining of a voice channel. /// - Connect = 0x00_00_10_00_00, + Connect = 1L << 20, + /// /// Allows for speaking in a voice channel. /// - Speak = 0x00_00_20_00_00, + Speak = 1L << 21, + /// /// Allows for muting members in a voice channel. /// - MuteMembers = 0x00_00_40_00_00, + MuteMembers = 1L << 22, + /// /// Allows for deafening of members in a voice channel. /// - DeafenMembers = 0x00_00_80_00_00, + DeafenMembers = 1L << 23, + /// /// Allows for moving of members between voice channels. /// - MoveMembers = 0x00_01_00_00_00, + MoveMembers = 1L << 24, + /// /// Allows for using voice-activity-detection in a voice channel. /// - UseVAD = 0x00_02_00_00_00, + UseVAD = 1L << 25, /// /// Allows for using priority speaker in a voice channel. /// - PrioritySpeaker = 0x00_00_00_01_00, + PrioritySpeaker = 1L << 8, /// /// Allows video streaming in a voice channel. /// - Stream = 0x00_00_00_02_00, + Stream = 1L << 9, // More General /// /// Allows management and editing of roles. /// - ManageRoles = 0x00_10_00_00_00, + ManageRoles = 1L << 28, + /// /// Allows management and editing of webhooks. /// - ManageWebhooks = 0x00_20_00_00_00, + ManageWebhooks = 1L << 29, /// /// Allows management and editing of emojis. /// - ManageEmojis = 0x00_40_00_00_00, + ManageEmojis = 1L << 30, /// /// Allows members to use slash commands in text channels. /// - UseApplicationCommands = 0x00_80_00_00_00, + UseApplicationCommands = 1L << 31, /// /// 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, + RequestToSpeak = 1L << 32, /// /// Allows for deleting and archiving threads, and viewing all private threads /// - ManageThreads = 0x04_00_00_00_00, + ManageThreads = 1L << 34, /// /// Allows for creating public threads. /// - CreatePublicThreads = 0x08_00_00_00_00, + CreatePublicThreads = 1L << 35, + /// /// Allows for creating private threads. /// - CreatePrivateThreads = 0x10_00_00_00_00, + CreatePrivateThreads = 1L << 36, + /// /// Allows the usage of custom stickers from other servers. /// - UseExternalStickers = 0x20_00_00_00_00, + UseExternalStickers = 1L << 37, + /// /// Allows for sending messages in threads. /// - SendMessagesInThreads = 0x40_00_00_00_00, + SendMessagesInThreads = 1L << 38, + /// /// Allows for launching activities (applications with the EMBEDDED flag) in a voice channel. /// - StartEmbeddedActivities = 0x80_00_00_00_00 + StartEmbeddedActivities = 1L << 39, + /// + /// Allows for using the soundboard in a voice channel. + /// + UseSoundboard = 1L << 42, + + /// + /// Allows members to edit and cancel events in this channel. + /// + CreateEvents = 1L << 44, } } diff --git a/src/Discord.Net.Core/Entities/Permissions/ChannelPermissions.cs b/src/Discord.Net.Core/Entities/Permissions/ChannelPermissions.cs index 3c6a804c..8ef01f26 100644 --- a/src/Discord.Net.Core/Entities/Permissions/ChannelPermissions.cs +++ b/src/Discord.Net.Core/Entities/Permissions/ChannelPermissions.cs @@ -18,17 +18,17 @@ namespace Discord /// /// Gets a that grants all permissions for text channels. /// - public static readonly ChannelPermissions Text = new(0b0_11111_0101100_0000000_1111111110001_010001); + public static readonly ChannelPermissions Text = new(0b01_001111_110010_110011_111101_111111_111101_010001); /// /// Gets a that grants all permissions for voice channels. /// - public static readonly ChannelPermissions Voice = new(0b1_11111_0101100_1111110_1111111111101_010001); // (0b1_00000_0000100_1111110_0000000011100_010001 (<- voice only perms) |= Text) - + public static readonly ChannelPermissions Voice = new(0b01_001010_001010_110011_111101_111111_111101_010001); // (0b1_00000_0000100_1111110_0000000011100_010001 (<- voice only perms) |= Text) + /// /// Gets a that grants all permissions for stage channels. /// - public static readonly ChannelPermissions Stage = new(0b0_00000_1000100_0111010_0000000010000_010001); + public static readonly ChannelPermissions Stage = new(0b0010_001110_010001_010101_111111_111001_010001); /// /// Gets a that grants all permissions for category channels. @@ -45,6 +45,11 @@ namespace Discord /// public static readonly ChannelPermissions Group = new(0b00000_1000110_0001101100000_000000); + /// + /// Gets a that grants all permissions for forum channels. + /// + public static readonly ChannelPermissions Forum = new(0b01_001110_010010_110011_111101_111111_111101_010001); + /// /// Gets a that grants all permissions for a given channel type. /// @@ -59,6 +64,7 @@ namespace Discord ICategoryChannel _ => Category, IDMChannel _ => DM, IGroupChannel _ => Group, + IForumChannel => Forum, _ => throw new ArgumentException(message: "Unknown channel type.", paramName: nameof(channel)), }; } @@ -66,70 +72,74 @@ namespace Discord /// Gets a packed value representing all the permissions in this . public ulong RawValue { get; } - /// If true, a user may create invites. + /// If , 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 , 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 , a user may add reactions. public bool AddReactions => Permissions.GetValue(RawValue, ChannelPermission.AddReactions); - /// If true, a user may view channels. + /// If , a user may view channels. public bool ViewChannel => Permissions.GetValue(RawValue, ChannelPermission.ViewChannel); - /// If true, a user may send messages. + /// If , a user may send messages. public bool SendMessages => Permissions.GetValue(RawValue, ChannelPermission.SendMessages); - /// If true, a user may send text-to-speech messages. + /// If , a user may send text-to-speech messages. public bool SendTTSMessages => Permissions.GetValue(RawValue, ChannelPermission.SendTTSMessages); - /// If true, a user may delete messages. + /// If , 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 , 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 , a user may send files. public bool AttachFiles => Permissions.GetValue(RawValue, ChannelPermission.AttachFiles); - /// If true, a user may read previous messages. + /// If , a user may read previous messages. public bool ReadMessageHistory => Permissions.GetValue(RawValue, ChannelPermission.ReadMessageHistory); - /// If true, a user may mention @everyone. + /// If , 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 , 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 , 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 , a user may speak in a voice channel. public bool Speak => Permissions.GetValue(RawValue, ChannelPermission.Speak); - /// If true, a user may mute users. + /// If , a user may mute users. public bool MuteMembers => Permissions.GetValue(RawValue, ChannelPermission.MuteMembers); - /// If true, a user may deafen users. + /// If , 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 , 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 , 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 , 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 , 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 implicitly grants all other permissions. + /// If , a user may adjust role permissions. This also implicitly grants all other permissions. public bool ManageRoles => Permissions.GetValue(RawValue, ChannelPermission.ManageRoles); - /// If true, a user may edit the webhooks for this channel. + /// If , 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. + /// If , 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. + /// If , 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. + /// If , 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. + /// If , 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. + /// If , 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. + /// If , 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. + /// If , a user may send messages in threads in this guild. public bool SendMessagesInThreads => Permissions.GetValue(RawValue, ChannelPermission.SendMessagesInThreads); - /// If true, a user launch application activities in voice channels in this guild. + /// If , a user launch application activities in voice channels in this guild. public bool StartEmbeddedActivities => Permissions.GetValue(RawValue, ChannelPermission.StartEmbeddedActivities); + /// If , a user can use soundboard in a voice channel. + public bool UseSoundboard => Permissions.GetValue(RawValue, ChannelPermission.UseSoundboard); + /// If , a user can edit and cancel events in this channel. + public bool CreateEvents => Permissions.GetValue(RawValue, ChannelPermission.CreateEvents); /// Creates a new with the provided packed value. public ChannelPermissions(ulong rawValue) { RawValue = rawValue; } @@ -164,7 +174,9 @@ namespace Discord bool? createPrivateThreads = null, bool? useExternalStickers = null, bool? sendMessagesInThreads = null, - bool? startEmbeddedActivities = null) + bool? startEmbeddedActivities = null, + bool? useSoundboard = null, + bool? createEvents = null) { ulong value = initialValue; @@ -198,6 +210,8 @@ namespace Discord Permissions.SetValue(ref value, useExternalStickers, ChannelPermission.UseExternalStickers); Permissions.SetValue(ref value, sendMessagesInThreads, ChannelPermission.SendMessagesInThreads); Permissions.SetValue(ref value, startEmbeddedActivities, ChannelPermission.StartEmbeddedActivities); + Permissions.SetValue(ref value, useSoundboard, ChannelPermission.UseSoundboard); + Permissions.SetValue(ref value, createEvents, ChannelPermission.CreateEvents); RawValue = value; } @@ -233,12 +247,14 @@ namespace Discord bool createPrivateThreads = false, bool useExternalStickers = false, bool sendMessagesInThreads = false, - bool startEmbeddedActivities = false) + bool startEmbeddedActivities = false, + bool useSoundboard = false, + bool createEvents = 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, useApplicationCommands, requestToSpeak, manageThreads, createPublicThreads, createPrivateThreads, useExternalStickers, sendMessagesInThreads, - startEmbeddedActivities) + startEmbeddedActivities, useSoundboard, createEvents) { } /// Creates a new from this one, changing the provided non-null permissions. @@ -272,7 +288,9 @@ namespace Discord bool? createPrivateThreads = null, bool? useExternalStickers = null, bool? sendMessagesInThreads = null, - bool? startEmbeddedActivities = null) + bool? startEmbeddedActivities = null, + bool? useSoundboard = null, + bool? createEvents = null) => new ChannelPermissions(RawValue, createInstantInvite, manageChannel, @@ -303,7 +321,9 @@ namespace Discord createPrivateThreads, useExternalStickers, sendMessagesInThreads, - startEmbeddedActivities); + startEmbeddedActivities, + useSoundboard, + createEvents); 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 39d4f801..41f3be24 100644 --- a/src/Discord.Net.Core/Entities/Permissions/GuildPermission.cs +++ b/src/Discord.Net.Core/Entities/Permissions/GuildPermission.cs @@ -10,7 +10,8 @@ namespace Discord /// /// Allows creation of instant invites. /// - CreateInstantInvite = 0x00_00_00_01, + CreateInstantInvite = 1L << 0, + /// /// Allows kicking members. /// @@ -18,7 +19,8 @@ namespace Discord /// This permission requires the owner account to use two-factor /// authentication when used on a guild that has server-wide 2FA enabled. /// - KickMembers = 0x00_00_00_02, + KickMembers = 1L << 1, + /// /// Allows banning members. /// @@ -26,7 +28,8 @@ namespace Discord /// This permission requires the owner account to use two-factor /// authentication when used on a guild that has server-wide 2FA enabled. /// - BanMembers = 0x00_00_00_04, + BanMembers = 1L << 2, + /// /// Allows all permissions and bypasses channel permission overwrites. /// @@ -34,7 +37,8 @@ namespace Discord /// This permission requires the owner account to use two-factor /// authentication when used on a guild that has server-wide 2FA enabled. /// - Administrator = 0x00_00_00_08, + Administrator = 1L << 3, + /// /// Allows management and editing of channels. /// @@ -42,7 +46,8 @@ namespace Discord /// This permission requires the owner account to use two-factor /// authentication when used on a guild that has server-wide 2FA enabled. /// - ManageChannels = 0x00_00_00_10, + ManageChannels = 1L << 4, + /// /// Allows management and editing of the guild. /// @@ -50,33 +55,39 @@ namespace Discord /// This permission requires the owner account to use two-factor /// authentication when used on a guild that has server-wide 2FA enabled. /// - ManageGuild = 0x00_00_00_20, + ManageGuild = 1L << 5, + /// /// Allows for viewing of guild insights /// - ViewGuildInsights = 0x00_08_00_00, + ViewGuildInsights = 1L << 19, // Text /// /// Allows for the addition of reactions to messages. /// - AddReactions = 0x00_00_00_40, + AddReactions = 1L << 6, + /// /// Allows for viewing of audit logs. /// - ViewAuditLog = 0x00_00_00_80, + ViewAuditLog = 1L << 7, + /// /// Allows guild members to view a channel, which includes reading messages in text channels. /// - ViewChannel = 0x00_00_04_00, + ViewChannel = 1L << 10, + /// /// Allows for sending messages in a channel /// - SendMessages = 0x00_00_08_00, + SendMessages = 1L << 11, + /// /// Allows for sending of text-to-speech messages. /// - SendTTSMessages = 0x00_00_10_00, + SendTTSMessages = 1L << 12, + /// /// Allows for deletion of other users messages. /// @@ -84,73 +95,83 @@ namespace Discord /// This permission requires the owner account to use two-factor /// authentication when used on a guild that has server-wide 2FA enabled. /// - ManageMessages = 0x00_00_20_00, + ManageMessages = 1L << 13, /// /// Allows links sent by users with this permission will be auto-embedded. /// - EmbedLinks = 0x00_00_40_00, + EmbedLinks = 1L << 14, + /// /// Allows for uploading images and files. /// - AttachFiles = 0x00_00_80_00, + AttachFiles = 1L << 15, + /// /// Allows for reading of message history. /// - ReadMessageHistory = 0x00_01_00_00, + ReadMessageHistory = 1 << 16, + /// /// Allows for using the @everyone tag to notify all users in a channel, and the @here tag to notify all /// online users in a channel. /// - MentionEveryone = 0x00_02_00_00, + MentionEveryone = 1L << 17, + /// /// Allows the usage of custom emojis from other servers. /// - UseExternalEmojis = 0x00_04_00_00, - - - // Voice + UseExternalEmojis = 1L << 18, + /// /// Allows for joining of a voice channel. /// - Connect = 0x00_10_00_00, + Connect = 1L << 20, + /// /// Allows for speaking in a voice channel. /// - Speak = 0x00_20_00_00, + Speak = 1L << 21, + /// /// Allows for muting members in a voice channel. /// - MuteMembers = 0x00_40_00_00, + MuteMembers = 1L << 22, + /// /// Allows for deafening of members in a voice channel. /// - DeafenMembers = 0x00_80_00_00, + DeafenMembers = 1L << 23, + /// /// Allows for moving of members between voice channels. /// - MoveMembers = 0x01_00_00_00, + MoveMembers = 1L << 24, + /// /// Allows for using voice-activity-detection in a voice channel. /// - UseVAD = 0x02_00_00_00, + UseVAD = 1L << 25, + /// /// Allows for using priority speaker in a voice channel. /// - PrioritySpeaker = 0x00_00_01_00, + PrioritySpeaker = 1L << 8, + /// /// Allows video streaming in a voice channel. /// - Stream = 0x00_00_02_00, - + Stream = 1L << 9, + // General 2 /// /// Allows for modification of own nickname. /// - ChangeNickname = 0x04_00_00_00, + ChangeNickname = 1L << 26, + /// /// Allows for modification of other users nicknames. /// - ManageNicknames = 0x08_00_00_00, + ManageNicknames = 1L << 27, /// /// Allows management and editing of roles. /// @@ -158,7 +179,8 @@ namespace Discord /// This permission requires the owner account to use two-factor /// authentication when used on a guild that has server-wide 2FA enabled. /// - ManageRoles = 0x10_00_00_00, + ManageRoles = 1L << 28, + /// /// Allows management and editing of webhooks. /// @@ -166,7 +188,8 @@ namespace Discord /// This permission requires the owner account to use two-factor /// authentication when used on a guild that has server-wide 2FA enabled. /// - ManageWebhooks = 0x20_00_00_00, + ManageWebhooks = 1L << 29, + /// /// Allows management and editing of emojis and stickers. /// @@ -174,19 +197,23 @@ namespace Discord /// This permission requires the owner account to use two-factor /// authentication when used on a guild that has server-wide 2FA enabled. /// - ManageEmojisAndStickers = 0x40_00_00_00, + ManageEmojisAndStickers = 1L << 30, + /// /// Allows members to use application commands like slash commands and context menus in text channels. /// - UseApplicationCommands = 0x80_00_00_00, + UseApplicationCommands = 1L << 31, + /// /// Allows for requesting to speak in stage channels. /// - RequestToSpeak = 0x01_00_00_00_00, + RequestToSpeak = 1L << 32, + /// /// Allows for creating, editing, and deleting guild scheduled events. /// - ManageEvents = 0x02_00_00_00_00, + ManageEvents = 1L << 33, + /// /// Allows for deleting and archiving threads, and viewing all private threads. /// @@ -194,30 +221,46 @@ namespace Discord /// This permission requires the owner account to use two-factor /// authentication when used on a guild that has server-wide 2FA enabled. /// - ManageThreads = 0x04_00_00_00_00, + ManageThreads = 1L << 34, + /// /// Allows for creating public threads. /// - CreatePublicThreads = 0x08_00_00_00_00, + CreatePublicThreads = 1L << 35, + /// /// Allows for creating private threads. /// - CreatePrivateThreads = 0x10_00_00_00_00, + CreatePrivateThreads = 1L << 36, + /// /// Allows the usage of custom stickers from other servers. /// - UseExternalStickers = 0x20_00_00_00_00, + UseExternalStickers = 1L << 37, + /// /// Allows for sending messages in threads. /// - SendMessagesInThreads = 0x40_00_00_00_00, + SendMessagesInThreads = 1L << 38, + /// /// Allows for launching activities (applications with the EMBEDDED flag) in a voice channel. /// - StartEmbeddedActivities = 0x80_00_00_00_00, + StartEmbeddedActivities = 1L << 39, + /// /// Allows for timing out users. /// - ModerateMembers = 0x01_00_00_00_00_00 + ModerateMembers = 1L << 40, + + /// + /// Allows for viewing role subscription insights. + /// + ViewMonetizationAnalytics = 1L << 41, + + /// + /// Allows for using the soundboard. + /// + UseSoundboard = 1L << 42, } } diff --git a/src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs b/src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs index 93edab77..4884a14e 100644 --- a/src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs +++ b/src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs @@ -18,92 +18,97 @@ namespace Discord /// Gets a packed value representing all the permissions in this . public ulong RawValue { get; } - /// If true, a user may create invites. + /// If , a user may create invites. public bool CreateInstantInvite => Permissions.GetValue(RawValue, GuildPermission.CreateInstantInvite); - /// If true, a user may ban users from the guild. + /// If , a user may ban users from the guild. public bool BanMembers => Permissions.GetValue(RawValue, GuildPermission.BanMembers); - /// If true, a user may kick users from the guild. + /// If , a user may kick users from the guild. public bool KickMembers => Permissions.GetValue(RawValue, GuildPermission.KickMembers); - /// If true, a user is granted all permissions, and cannot have them revoked via channel permissions. + /// If , a user is granted all permissions, and cannot have them revoked via channel permissions. public bool Administrator => Permissions.GetValue(RawValue, GuildPermission.Administrator); - /// If true, a user may create, delete and modify channels. + /// If , a user may create, delete and modify channels. public bool ManageChannels => Permissions.GetValue(RawValue, GuildPermission.ManageChannels); - /// If true, a user may adjust guild properties. + /// If , a user may adjust guild properties. public bool ManageGuild => Permissions.GetValue(RawValue, GuildPermission.ManageGuild); - /// If true, a user may add reactions. + /// If , a user may add reactions. public bool AddReactions => Permissions.GetValue(RawValue, GuildPermission.AddReactions); - /// If true, a user may view the audit log. + /// If , a user may view the audit log. public bool ViewAuditLog => Permissions.GetValue(RawValue, GuildPermission.ViewAuditLog); - /// If true, a user may view the guild insights. + /// If , a user may view the guild insights. public bool ViewGuildInsights => Permissions.GetValue(RawValue, GuildPermission.ViewGuildInsights); /// If True, a user may view channels. public bool ViewChannel => Permissions.GetValue(RawValue, GuildPermission.ViewChannel); /// If True, a user may send messages. public bool SendMessages => Permissions.GetValue(RawValue, GuildPermission.SendMessages); - /// If true, a user may send text-to-speech messages. + /// If , a user may send text-to-speech messages. public bool SendTTSMessages => Permissions.GetValue(RawValue, GuildPermission.SendTTSMessages); - /// If true, a user may delete messages. + /// If , a user may delete messages. public bool ManageMessages => Permissions.GetValue(RawValue, GuildPermission.ManageMessages); - /// If true, Discord will auto-embed links sent by this user. + /// If , Discord will auto-embed links sent by this user. public bool EmbedLinks => Permissions.GetValue(RawValue, GuildPermission.EmbedLinks); - /// If true, a user may send files. + /// If , a user may send files. public bool AttachFiles => Permissions.GetValue(RawValue, GuildPermission.AttachFiles); - /// If true, a user may read previous messages. + /// If , a user may read previous messages. public bool ReadMessageHistory => Permissions.GetValue(RawValue, GuildPermission.ReadMessageHistory); - /// If true, a user may mention @everyone. + /// If , a user may mention @everyone. public bool MentionEveryone => Permissions.GetValue(RawValue, GuildPermission.MentionEveryone); - /// If true, a user may use custom emoji from other guilds. + /// If , a user may use custom emoji from other guilds. public bool UseExternalEmojis => Permissions.GetValue(RawValue, GuildPermission.UseExternalEmojis); - /// If true, a user may connect to a voice channel. + /// If , a user may connect to a voice channel. public bool Connect => Permissions.GetValue(RawValue, GuildPermission.Connect); - /// If true, a user may speak in a voice channel. + /// If , a user may speak in a voice channel. public bool Speak => Permissions.GetValue(RawValue, GuildPermission.Speak); - /// If true, a user may mute users. + /// If , a user may mute users. public bool MuteMembers => Permissions.GetValue(RawValue, GuildPermission.MuteMembers); - /// If true, a user may deafen users. + /// If , a user may deafen users. public bool DeafenMembers => Permissions.GetValue(RawValue, GuildPermission.DeafenMembers); - /// If true, a user may move other users between voice channels. + /// If , a user may move other users between voice channels. public bool MoveMembers => Permissions.GetValue(RawValue, GuildPermission.MoveMembers); - /// If true, a user may use voice-activity-detection rather than push-to-talk. + /// If , a user may use voice-activity-detection rather than push-to-talk. public bool UseVAD => Permissions.GetValue(RawValue, GuildPermission.UseVAD); /// If True, a user may use priority speaker in a voice channel. public bool PrioritySpeaker => Permissions.GetValue(RawValue, GuildPermission.PrioritySpeaker); /// If True, a user may stream video in a voice channel. public bool Stream => Permissions.GetValue(RawValue, GuildPermission.Stream); - /// If true, a user may change their own nickname. + /// If , a user may change their own nickname. public bool ChangeNickname => Permissions.GetValue(RawValue, GuildPermission.ChangeNickname); - /// If true, a user may change the nickname of other users. + /// If , a user may change the nickname of other users. public bool ManageNicknames => Permissions.GetValue(RawValue, GuildPermission.ManageNicknames); - /// If true, a user may adjust roles. + /// If , a user may adjust roles. public bool ManageRoles => Permissions.GetValue(RawValue, GuildPermission.ManageRoles); - /// If true, a user may edit the webhooks for this guild. + /// If , a user may edit the webhooks for this guild. public bool ManageWebhooks => Permissions.GetValue(RawValue, GuildPermission.ManageWebhooks); - /// If true, a user may edit the emojis and stickers for this guild. + /// If , 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. + /// If , a user may use slash commands in this guild. public bool UseApplicationCommands => Permissions.GetValue(RawValue, GuildPermission.UseApplicationCommands); - /// If true, a user may request to speak in stage channels. + /// If , a user may request to speak in stage channels. public bool RequestToSpeak => Permissions.GetValue(RawValue, GuildPermission.RequestToSpeak); - /// If true, a user may create, edit, and delete events. + /// If , a user may create, edit, and delete events. public bool ManageEvents => Permissions.GetValue(RawValue, GuildPermission.ManageEvents); - /// If true, a user may manage threads in this guild. + /// If , a user may manage threads in this guild. public bool ManageThreads => Permissions.GetValue(RawValue, GuildPermission.ManageThreads); - /// If true, a user may create public threads in this guild. + /// If , a user may create public threads in this guild. public bool CreatePublicThreads => Permissions.GetValue(RawValue, GuildPermission.CreatePublicThreads); - /// If true, a user may create private threads in this guild. + /// If , a user may create private threads in this guild. public bool CreatePrivateThreads => Permissions.GetValue(RawValue, GuildPermission.CreatePrivateThreads); - /// If true, a user may use external stickers in this guild. + /// If , 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. + /// If , a user may send messages in threads in this guild. public bool SendMessagesInThreads => Permissions.GetValue(RawValue, GuildPermission.SendMessagesInThreads); - /// If true, a user launch application activities in voice channels in this guild. + /// If , a user launch application activities in voice channels in this guild. public bool StartEmbeddedActivities => Permissions.GetValue(RawValue, GuildPermission.StartEmbeddedActivities); - /// If true, a user can timeout other users in this guild. + /// If , a user can timeout other users in this guild. public bool ModerateMembers => Permissions.GetValue(RawValue, GuildPermission.ModerateMembers); + /// If , a user can use soundboard in this guild. + public bool UseSoundboard => Permissions.GetValue(RawValue, GuildPermission.UseSoundboard); + /// If , a user can view monetization analytics in this guild. + public bool ViewMonetizationAnalytics => Permissions.GetValue(RawValue, GuildPermission.ViewMonetizationAnalytics); + /// Creates a new with the provided packed value. public GuildPermissions(ulong rawValue) { RawValue = rawValue; } @@ -151,7 +156,9 @@ namespace Discord bool? useExternalStickers = null, bool? sendMessagesInThreads = null, bool? startEmbeddedActivities = null, - bool? moderateMembers = null) + bool? moderateMembers = null, + bool? useSoundboard = null, + bool? viewMonetizationAnalytics = null) { ulong value = initialValue; @@ -196,6 +203,8 @@ namespace Discord Permissions.SetValue(ref value, sendMessagesInThreads, GuildPermission.SendMessagesInThreads); Permissions.SetValue(ref value, startEmbeddedActivities, GuildPermission.StartEmbeddedActivities); Permissions.SetValue(ref value, moderateMembers, GuildPermission.ModerateMembers); + Permissions.SetValue(ref value, useSoundboard, GuildPermission.UseSoundboard); + Permissions.SetValue(ref value, viewMonetizationAnalytics, GuildPermission.ViewMonetizationAnalytics); RawValue = value; } @@ -242,7 +251,9 @@ namespace Discord bool useExternalStickers = false, bool sendMessagesInThreads = false, bool startEmbeddedActivities = false, - bool moderateMembers = false) + bool moderateMembers = false, + bool useSoundboard = false, + bool viewMonetizationAnalytics = false) : this(0, createInstantInvite: createInstantInvite, manageRoles: manageRoles, @@ -284,7 +295,9 @@ namespace Discord useExternalStickers: useExternalStickers, sendMessagesInThreads: sendMessagesInThreads, startEmbeddedActivities: startEmbeddedActivities, - moderateMembers: moderateMembers) + moderateMembers: moderateMembers, + useSoundboard: useSoundboard, + viewMonetizationAnalytics: viewMonetizationAnalytics) { } /// Creates a new from this one, changing the provided non-null permissions. @@ -329,20 +342,22 @@ namespace Discord bool? useExternalStickers = null, bool? sendMessagesInThreads = null, bool? startEmbeddedActivities = null, - bool? moderateMembers = null) + bool? moderateMembers = null, + bool? useSoundboard = null, + bool? viewMonetizationAnalytics = null) => new GuildPermissions(RawValue, createInstantInvite, kickMembers, banMembers, administrator, manageChannels, manageGuild, addReactions, viewAuditLog, viewGuildInsights, viewChannel, sendMessages, sendTTSMessages, manageMessages, embedLinks, attachFiles, readMessageHistory, mentionEveryone, useExternalEmojis, connect, speak, muteMembers, deafenMembers, moveMembers, useVoiceActivation, prioritySpeaker, stream, changeNickname, manageNicknames, manageRoles, manageWebhooks, manageEmojisAndStickers, useApplicationCommands, requestToSpeak, manageEvents, manageThreads, createPublicThreads, createPrivateThreads, useExternalStickers, sendMessagesInThreads, - startEmbeddedActivities, moderateMembers); + startEmbeddedActivities, moderateMembers, useSoundboard, viewMonetizationAnalytics); /// /// Returns a value that indicates if a specific is enabled /// in these permissions. /// /// The permission value to check for. - /// true if the permission is enabled, false otherwise. + /// if the permission is enabled, false otherwise. public bool Has(GuildPermission permission) => Permissions.GetValue(RawValue, permission); /// diff --git a/test/Discord.Net.Tests.Unit/ChannelPermissionsTests.cs b/test/Discord.Net.Tests.Unit/ChannelPermissionsTests.cs index 2cab8fa2..f8300cc6 100644 --- a/test/Discord.Net.Tests.Unit/ChannelPermissionsTests.cs +++ b/test/Discord.Net.Tests.Unit/ChannelPermissionsTests.cs @@ -89,10 +89,13 @@ namespace Discord AssertFlag(() => new ChannelPermissions(createPrivateThreads: true), ChannelPermission.CreatePrivateThreads); AssertFlag(() => new ChannelPermissions(createPublicThreads: true), ChannelPermission.CreatePublicThreads); AssertFlag(() => new ChannelPermissions(sendMessagesInThreads: true), ChannelPermission.SendMessagesInThreads); + AssertFlag(() => new ChannelPermissions(startEmbeddedActivities: true), ChannelPermission.StartEmbeddedActivities); + AssertFlag(() => new ChannelPermissions(useSoundboard: true), ChannelPermission.UseSoundboard); + AssertFlag(() => new ChannelPermissions(createEvents: true), ChannelPermission.CreateEvents); } /// - /// Tests the behavior of + /// Tests the behavior of /// with each of the parameters. /// [Fact] diff --git a/test/Discord.Net.Tests.Unit/GuildPermissionsTests.cs b/test/Discord.Net.Tests.Unit/GuildPermissionsTests.cs index ce5d0eb8..e259cc01 100644 --- a/test/Discord.Net.Tests.Unit/GuildPermissionsTests.cs +++ b/test/Discord.Net.Tests.Unit/GuildPermissionsTests.cs @@ -100,6 +100,8 @@ namespace Discord AssertFlag(() => new GuildPermissions(createPrivateThreads: true), GuildPermission.CreatePrivateThreads); AssertFlag(() => new GuildPermissions(useExternalStickers: true), GuildPermission.UseExternalStickers); AssertFlag(() => new GuildPermissions(moderateMembers: true), GuildPermission.ModerateMembers); + AssertFlag(() => new GuildPermissions(viewMonetizationAnalytics: true), GuildPermission.ViewMonetizationAnalytics); + AssertFlag(() => new GuildPermissions(useSoundboard: true), GuildPermission.UseSoundboard); } ///