Browse Source

Update SlashCommandBuilder.cs

pull/2457/head
Proddy GitHub 2 years ago
parent
commit
d72aed56b0
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 19 deletions
  1. +10
    -19
      src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs

+ 10
- 19
src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs View File

@@ -107,13 +107,11 @@ namespace Discord
Name = Name, Name = Name,
Description = Description, Description = Description,
IsDefaultPermission = IsDefaultPermission, IsDefaultPermission = IsDefaultPermission,
NameLocalizations = _nameLocalizations,
DescriptionLocalizations = _descriptionLocalizations,
IsDMEnabled = IsDMEnabled, IsDMEnabled = IsDMEnabled,
DefaultMemberPermissions = DefaultMemberPermissions ?? Optional<GuildPermission>.Unspecified DefaultMemberPermissions = DefaultMemberPermissions ?? Optional<GuildPermission>.Unspecified
}; };
if (_nameLocalizations is not null)
props.NameLocalizations = _nameLocalizations;
if (_descriptionLocalizations is not null)
props.DescriptionLocalizations = _descriptionLocalizations;


if (Options != null && Options.Any()) if (Options != null && Options.Any())
{ {
@@ -540,7 +538,7 @@ namespace Discord
if (isStrType && MaxLength is not null && MaxLength < 1) if (isStrType && MaxLength is not null && MaxLength < 1)
throw new InvalidOperationException("MaxLength cannot be smaller than 1."); throw new InvalidOperationException("MaxLength cannot be smaller than 1.");


var props = new ApplicationCommandOptionProperties
return new ApplicationCommandOptionProperties
{ {
Name = Name, Name = Name,
Description = Description, Description = Description,
@@ -555,15 +553,11 @@ namespace Discord
ChannelTypes = ChannelTypes, ChannelTypes = ChannelTypes,
MinValue = MinValue, MinValue = MinValue,
MaxValue = MaxValue, MaxValue = MaxValue,
NameLocalizations = _nameLocalizations,
DescriptionLocalizations = _descriptionLocalizations,
MinLength = MinLength, MinLength = MinLength,
MaxLength = MaxLength, MaxLength = MaxLength,
}; };
if (_nameLocalizations is not null)
props.NameLocalizations = _nameLocalizations;
if (_descriptionLocalizations is not null)
props.DescriptionLocalizations = _descriptionLocalizations;
return props;
} }


/// <summary> /// <summary>
@@ -741,16 +735,13 @@ namespace Discord
Preconditions.AtLeast(str.Length, 1, nameof(value)); Preconditions.AtLeast(str.Length, 1, nameof(value));
Preconditions.AtMost(str.Length, 100, nameof(value)); Preconditions.AtMost(str.Length, 100, nameof(value));
} }
var props = new ApplicationCommandOptionChoiceProperties
Choices.Add(new ApplicationCommandOptionChoiceProperties
{ {
Name = name, Name = name,
Value = value
};
if (nameLocalizations is not null)
props.NameLocalizations = nameLocalizations;
Choices.Add(props);
Value = value,
NameLocalizations = nameLocalizations
});


return this; return this;
} }


Loading…
Cancel
Save