From 4f7324d3840b4a27b2f9c2de3a6b4e621f143315 Mon Sep 17 00:00:00 2001 From: Misha133 Date: Tue, 13 Dec 2022 21:08:55 +0300 Subject: [PATCH] add `nsfw` prop to command builders --- .../ContextMenus/MessageCommandBuilder.cs | 21 +++++++++++++++++-- .../ContextMenus/UserCommandBuilder.cs | 21 +++++++++++++++++-- .../SlashCommands/SlashCommandBuilder.cs | 21 +++++++++++++++++-- 3 files changed, 57 insertions(+), 6 deletions(-) diff --git a/src/Discord.Net.Core/Entities/Interactions/ContextMenus/MessageCommandBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/ContextMenus/MessageCommandBuilder.cs index 613e30376..b7037cc63 100644 --- a/src/Discord.Net.Core/Entities/Interactions/ContextMenus/MessageCommandBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/ContextMenus/MessageCommandBuilder.cs @@ -46,6 +46,11 @@ namespace Discord /// public bool IsDMEnabled { get; set; } = true; + /// + /// Gets or sets whether or not this command is age restricted. + /// + public bool IsNsfw{ get; set; } = false; + /// /// Gets or sets the default permission required to use this slash command. /// @@ -68,7 +73,8 @@ namespace Discord IsDefaultPermission = IsDefaultPermission, IsDMEnabled = IsDMEnabled, DefaultMemberPermissions = DefaultMemberPermissions ?? Optional.Unspecified, - NameLocalizations = NameLocalizations + NameLocalizations = NameLocalizations, + IsNsfw = IsNsfw, }; return props; @@ -123,7 +129,7 @@ namespace Discord } /// - /// Sets whether or not this command can be used in dms + /// Sets whether or not this command can be used in dms. /// /// if the command is available in dms, otherwise . /// The current builder. @@ -133,6 +139,17 @@ namespace Discord return this; } + /// + /// Sets whether or not this command is age restricted. + /// + /// if the command is age restricted, otherwise . + /// The current builder. + public MessageCommandBuilder WithNsfw(bool permission) + { + IsNsfw = permission; + return this; + } + /// /// Adds a new entry to the collection. /// diff --git a/src/Discord.Net.Core/Entities/Interactions/ContextMenus/UserCommandBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/ContextMenus/UserCommandBuilder.cs index 8ac524582..85efc4938 100644 --- a/src/Discord.Net.Core/Entities/Interactions/ContextMenus/UserCommandBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/ContextMenus/UserCommandBuilder.cs @@ -46,6 +46,11 @@ namespace Discord /// public bool IsDMEnabled { get; set; } = true; + /// + /// Gets or sets whether or not this command is age restricted. + /// + public bool IsNsfw { get; set; } = false; + /// /// Gets or sets the default permission required to use this slash command. /// @@ -66,7 +71,8 @@ namespace Discord IsDefaultPermission = IsDefaultPermission, IsDMEnabled = IsDMEnabled, DefaultMemberPermissions = DefaultMemberPermissions ?? Optional.Unspecified, - NameLocalizations = NameLocalizations + NameLocalizations = NameLocalizations, + IsNsfw = IsNsfw, }; return props; @@ -121,7 +127,7 @@ namespace Discord } /// - /// Sets whether or not this command can be used in dms + /// Sets whether or not this command can be used in dms. /// /// if the command is available in dms, otherwise . /// The current builder. @@ -131,6 +137,17 @@ namespace Discord return this; } + /// + /// Sets whether or not this command is age restricted. + /// + /// if the command is age restricted, otherwise . + /// The current builder. + public UserCommandBuilder WithNsfw(bool permission) + { + IsNsfw = permission; + return this; + } + /// /// Adds a new entry to the collection. /// diff --git a/src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs index 03fb24c8b..b0b8e9600 100644 --- a/src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs @@ -84,6 +84,11 @@ namespace Discord /// Gets or sets whether or not this command can be used in DMs. /// public bool IsDMEnabled { get; set; } = true; + + /// + /// Gets or sets whether or not this command is age restricted. + /// + public bool IsNsfw { get; set; } = false; /// /// Gets or sets the default permission required to use this slash command. @@ -110,7 +115,8 @@ namespace Discord NameLocalizations = _nameLocalizations, DescriptionLocalizations = _descriptionLocalizations, IsDMEnabled = IsDMEnabled, - DefaultMemberPermissions = DefaultMemberPermissions ?? Optional.Unspecified + DefaultMemberPermissions = DefaultMemberPermissions ?? Optional.Unspecified, + IsNsfw = IsNsfw, }; if (Options != null && Options.Any()) @@ -161,7 +167,7 @@ namespace Discord } /// - /// Sets whether or not this command can be used in dms + /// Sets whether or not this command can be used in dms. /// /// if the command is available in dms, otherwise . /// The current builder. @@ -171,6 +177,17 @@ namespace Discord return this; } + /// + /// Sets whether or not this command is age restricted. + /// + /// if the command is age restricted, otherwise . + /// The current builder. + public SlashCommandBuilder WithNsfw(bool permission) + { + IsNsfw = permission; + return this; + } + /// /// Sets the default member permissions required to use this application command. ///