diff --git a/src/Discord.Net.Core/Entities/Permissions/ApplicationCommandPermissionTarget.cs b/src/Discord.Net.Core/Entities/Permissions/ApplicationCommandPermissionTarget.cs index 9a99b34f1d..aa81ac6fc3 100644 --- a/src/Discord.Net.Core/Entities/Permissions/ApplicationCommandPermissionTarget.cs +++ b/src/Discord.Net.Core/Entities/Permissions/ApplicationCommandPermissionTarget.cs @@ -12,6 +12,10 @@ public enum ApplicationCommandPermissionTarget /// /// The target of the permission is a user. /// - User = 2 + User = 2, + /// + /// The target of the permission is a channel. + /// + Channel = 3 } } diff --git a/src/Discord.Net.Core/Entities/Permissions/ApplicationCommandPermissions.cs b/src/Discord.Net.Core/Entities/Permissions/ApplicationCommandPermissions.cs index 28a6455e20..a5819fefea 100644 --- a/src/Discord.Net.Core/Entities/Permissions/ApplicationCommandPermissions.cs +++ b/src/Discord.Net.Core/Entities/Permissions/ApplicationCommandPermissions.cs @@ -58,5 +58,61 @@ public ApplicationCommandPermission(IRole target, bool allow) Permission = allow; TargetType = ApplicationCommandPermissionTarget.Role; } + + /// + /// Creates a new targeting . + /// + /// The channel you want to target this permission value for. + /// The value of this permission. + public ApplicationCommandPermission(IChannel channel, bool allow) + { + TargetId = channel.Id; + Permission = allow; + TargetType = ApplicationCommandPermissionTarget.Channel; + } + + /// + /// Creates a new targeting @everyone in a guild. + /// + /// Id of the target guild. + /// The value of this permission. + /// + /// Instance of targeting @everyone in a guild. + /// + public static ApplicationCommandPermission ForEveryone(ulong guildId, bool allow) => + new(guildId, ApplicationCommandPermissionTarget.User, allow); + + /// + /// Creates a new targeting @everyone in a guild. + /// + /// Target guild. + /// The value of this permission. + /// + /// Instance of targeting @everyone in a guild. + /// + public static ApplicationCommandPermission ForEveryone(IGuild guild, bool allow) => + ForEveryone(guild.Id, allow); + + /// + /// Creates a new targeting every channel in a guild. + /// + /// Id of the target guild. + /// The value of this permission. + /// + /// Instance of targeting everychannel in a guild. + /// + public static ApplicationCommandPermission ForAllChannels(ulong guildId, bool allow) => + new(guildId - 1, ApplicationCommandPermissionTarget.Channel, allow); + + /// + /// Creates a new targeting every channel in a guild. + /// + /// Target guild. + /// The value of this permission. + /// + /// Instance of targeting everychannel in a guild. + /// + public static ApplicationCommandPermission ForAllChannels(IGuild guild, bool allow) => + ForAllChannels(guild.Id, allow); } }