From d72aed56b0a67771a09e66781c8c716d0ce69eb7 Mon Sep 17 00:00:00 2001 From: Proddy Date: Sat, 10 Sep 2022 20:58:34 +0100 Subject: [PATCH] Update SlashCommandBuilder.cs --- .../SlashCommands/SlashCommandBuilder.cs | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs index c1ca4976b..03fb24c8b 100644 --- a/src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs @@ -107,13 +107,11 @@ namespace Discord Name = Name, Description = Description, IsDefaultPermission = IsDefaultPermission, + NameLocalizations = _nameLocalizations, + DescriptionLocalizations = _descriptionLocalizations, IsDMEnabled = IsDMEnabled, DefaultMemberPermissions = DefaultMemberPermissions ?? Optional.Unspecified }; - if (_nameLocalizations is not null) - props.NameLocalizations = _nameLocalizations; - if (_descriptionLocalizations is not null) - props.DescriptionLocalizations = _descriptionLocalizations; if (Options != null && Options.Any()) { @@ -540,7 +538,7 @@ namespace Discord if (isStrType && MaxLength is not null && MaxLength < 1) throw new InvalidOperationException("MaxLength cannot be smaller than 1."); - var props = new ApplicationCommandOptionProperties + return new ApplicationCommandOptionProperties { Name = Name, Description = Description, @@ -555,15 +553,11 @@ namespace Discord ChannelTypes = ChannelTypes, MinValue = MinValue, MaxValue = MaxValue, + NameLocalizations = _nameLocalizations, + DescriptionLocalizations = _descriptionLocalizations, MinLength = MinLength, MaxLength = MaxLength, }; - if (_nameLocalizations is not null) - props.NameLocalizations = _nameLocalizations; - if (_descriptionLocalizations is not null) - props.DescriptionLocalizations = _descriptionLocalizations; - - return props; } /// @@ -741,16 +735,13 @@ namespace Discord Preconditions.AtLeast(str.Length, 1, nameof(value)); Preconditions.AtMost(str.Length, 100, nameof(value)); } - - var props = new ApplicationCommandOptionChoiceProperties + + Choices.Add(new ApplicationCommandOptionChoiceProperties { Name = name, - Value = value - }; - if (nameLocalizations is not null) - props.NameLocalizations = nameLocalizations; - - Choices.Add(props); + Value = value, + NameLocalizations = nameLocalizations + }); return this; }