diff --git a/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOption.cs b/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOption.cs
index bf512e0ab..9a69d9d18 100644
--- a/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOption.cs
+++ b/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOption.cs
@@ -55,17 +55,17 @@ namespace Discord
///
/// Gets or sets whether or not this options is the first required option for the user to complete. only one option can be default.
///
- public bool? Default { get; set; }
+ public bool? IsDefault { get; set; }
///
/// Gets or sets if the option is required.
///
- public bool? Required { get; set; }
+ public bool? IsRequired { get; set; }
///
/// Gets or sets whether or not this option supports autocomplete.
///
- public bool Autocomplete { get; set; }
+ public bool IsAutocomplete { get; set; }
///
/// Gets or sets the smallest number value the user can input.
diff --git a/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandProperties.cs b/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandProperties.cs
index b3a4b8e92..501a0e905 100644
--- a/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandProperties.cs
+++ b/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandProperties.cs
@@ -13,9 +13,9 @@ namespace Discord
public Optional Name { get; set; }
///
- /// Gets whether the command is enabled by default when the app is added to a guild. Default is .
+ /// Gets or sets whether the command is enabled by default when the app is added to a guild. Default is
///
- public Optional DefaultPermission { get; set; }
+ public Optional IsDefaultPermission { get; set; }
internal ApplicationCommandProperties() { }
}
diff --git a/src/Discord.Net.Core/Entities/Interactions/ContextMenus/MessageCommandBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/ContextMenus/MessageCommandBuilder.cs
index def5b9c3a..c7a7cf741 100644
--- a/src/Discord.Net.Core/Entities/Interactions/ContextMenus/MessageCommandBuilder.cs
+++ b/src/Discord.Net.Core/Entities/Interactions/ContextMenus/MessageCommandBuilder.cs
@@ -44,7 +44,7 @@ namespace Discord
var props = new MessageCommandProperties
{
Name = Name,
- DefaultPermission = IsDefaultPermission
+ IsDefaultPermission = IsDefaultPermission
};
return props;
diff --git a/src/Discord.Net.Core/Entities/Interactions/ContextMenus/UserCommandBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/ContextMenus/UserCommandBuilder.cs
index 9af02a027..bd1078be3 100644
--- a/src/Discord.Net.Core/Entities/Interactions/ContextMenus/UserCommandBuilder.cs
+++ b/src/Discord.Net.Core/Entities/Interactions/ContextMenus/UserCommandBuilder.cs
@@ -42,7 +42,7 @@ namespace Discord
var props = new UserCommandProperties
{
Name = Name,
- DefaultPermission = IsDefaultPermission
+ IsDefaultPermission = IsDefaultPermission
};
return props;
diff --git a/src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs
index 25c1f1dd9..73898ddd0 100644
--- a/src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs
+++ b/src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs
@@ -6,7 +6,7 @@ using System.Text.RegularExpressions;
namespace Discord
{
///
- /// A class used to build slash commands.
+ /// Represents a class used to build slash commands.
///
public class SlashCommandBuilder
{
@@ -24,7 +24,7 @@ namespace Discord
public const int MaxOptionsCount = 25;
///
- /// The name of this slash command.
+ /// Gets or sets the name of this slash command.
///
public string Name
{
@@ -45,8 +45,7 @@ namespace Discord
}
///
- /// A 1-100 length description of this slash command.
- /// The description is not allowed to be null.
+ /// Gets or sets a 1-100 length description of this slash command
///
public string Description
{
@@ -75,9 +74,9 @@ namespace Discord
}
///
- /// Whether the command is enabled by default when the app is added to a guild
+ /// Gets or sets whether the command is enabled by default when the app is added to a guild
///
- public bool DefaultPermission { get; set; } = true;
+ public bool IsDefaultPermission { get; set; } = true;
private string _name;
private string _description;
@@ -86,21 +85,21 @@ namespace Discord
///
/// Build the current builder into a class.
///
- /// A that can be used to create slash commands over rest.
+ /// A that can be used to create slash commands.
public SlashCommandProperties Build()
{
var props = new SlashCommandProperties
{
Name = Name,
Description = Description,
- DefaultPermission = DefaultPermission
+ IsDefaultPermission = IsDefaultPermission,
};
if (Options != null && Options.Any())
{
var options = new List();
- Options.OrderByDescending(x => x.Required ?? false).ToList().ForEach(x => options.Add(x.Build()));
+ Options.OrderByDescending(x => x.IsRequired ?? false).ToList().ForEach(x => options.Add(x.Build()));
props.Options = options;
}
@@ -139,7 +138,7 @@ namespace Discord
/// The current builder.
public SlashCommandBuilder WithDefaultPermission(bool value)
{
- DefaultPermission = value;
+ IsDefaultPermission = value;
return this;
}
@@ -149,7 +148,7 @@ namespace Discord
/// The name of the option to add.
/// The type of this option.
/// The description of this option.
- /// If this option is required for this command.
+ /// If this option is required for this command.
/// If this option is the default option.
/// If this option is set to autocomplete.
/// The options of the option to add.
@@ -159,7 +158,7 @@ namespace Discord
/// The largest number value the user can input.
/// The current builder.
public SlashCommandBuilder AddOption(string name, ApplicationCommandOptionType type,
- string description, bool? required = null, bool? isDefault = null, bool isAutocomplete = false, double? minValue = null, double? maxValue = null,
+ string description, bool? isRequired = null, bool? isDefault = null, bool isAutocomplete = false, double? minValue = null, double? maxValue = null,
List options = null, List channelTypes = null, params ApplicationCommandOptionChoiceProperties[] choices)
{
// Make sure the name matches the requirements from discord
@@ -178,18 +177,18 @@ namespace Discord
Preconditions.AtMost(description.Length, MaxDescriptionLength, nameof(description));
// make sure theres only one option with default set to true
- if (isDefault == true && Options?.Any(x => x.Default == true) == true)
+ if (isDefault == true && Options?.Any(x => x.IsDefault == true) == true)
throw new ArgumentException("There can only be one command option with default set to true!", nameof(isDefault));
var option = new SlashCommandOptionBuilder
{
Name = name,
Description = description,
- Required = required,
- Default = isDefault,
+ IsRequired = isRequired,
+ IsDefault = isDefault,
Options = options,
Type = type,
- Autocomplete = isAutocomplete,
+ IsAutocomplete = isAutocomplete,
Choices = (choices ?? Array.Empty()).ToList(),
ChannelTypes = channelTypes,
MinValue = minValue,
@@ -199,16 +198,6 @@ namespace Discord
return AddOption(option);
}
- ///
- /// Adds an option to the current slash command.
- ///
- /// The name of the option to add.
- /// The type of this option.
- /// The description of this option.
- /// The current builder.
- public SlashCommandBuilder AddOption(string name, ApplicationCommandOptionType type, string description)
- => AddOption(name, type, description, options: null, choices: null);
-
///
/// Adds an option to this slash command.
///
@@ -313,17 +302,17 @@ namespace Discord
///
/// Gets or sets whether or not this options is the first required option for the user to complete. only one option can be default.
///
- public bool? Default { get; set; }
+ public bool? IsDefault { get; set; }
///
/// Gets or sets if the option is required.
///
- public bool? Required { get; set; }
+ public bool? IsRequired { get; set; } = null;
///
/// Gets or sets whether or not this option supports autocomplete.
///
- public bool Autocomplete { get; set; }
+ public bool IsAutocomplete { get; set; }
///
/// Gets or sets the smallest number value the user can input.
@@ -375,14 +364,14 @@ namespace Discord
{
Name = Name,
Description = Description,
- Default = Default,
- Required = Required,
+ IsDefault = IsDefault,
+ IsRequired = IsRequired,
Type = Type,
Options = Options?.Count > 0
- ? Options.OrderByDescending(x => x.Required ?? false).Select(x => x.Build()).ToList()
+ ? Options.OrderByDescending(x => x.IsRequired ?? false).Select(x => x.Build()).ToList()
: new List(),
Choices = Choices,
- Autocomplete = Autocomplete,
+ IsAutocomplete = IsAutocomplete,
ChannelTypes = ChannelTypes,
MinValue = MinValue,
MaxValue = MaxValue
@@ -395,7 +384,7 @@ namespace Discord
/// The name of the option to add.
/// The type of this option.
/// The description of this option.
- /// If this option is required for this command.
+ /// If this option is required for this command.
/// If this option is the default option.
/// If this option supports autocomplete.
/// The options of the option to add.
@@ -424,16 +413,16 @@ namespace Discord
Preconditions.AtMost(description.Length, SlashCommandBuilder.MaxDescriptionLength, nameof(description));
// make sure theres only one option with default set to true
- if (isDefault && Options?.Any(x => x.Default == true) == true)
+ if (isDefault && Options?.Any(x => x.IsDefault == true) == true)
throw new ArgumentException("There can only be one command option with default set to true!", nameof(isDefault));
var option = new SlashCommandOptionBuilder
{
Name = name,
Description = description,
- Required = required,
- Default = isDefault,
- Autocomplete = isAutocomplete,
+ IsRequired = required,
+ IsDefault = isDefault,
+ IsAutocomplete = isAutocomplete,
MinValue = minValue,
MaxValue = maxValue,
Options = options,
@@ -470,23 +459,40 @@ namespace Discord
/// The current builder.
public SlashCommandOptionBuilder AddChoice(string name, int value)
{
- Choices ??= new List();
-
- if (Choices.Count >= MaxChoiceCount)
- throw new InvalidOperationException($"Cannot add more than {MaxChoiceCount} choices!");
-
- Preconditions.NotNull(name, nameof(name));
+ return AddChoiceInternal(name, value);
+ }
- Preconditions.AtLeast(name.Length, 1, nameof(name));
- Preconditions.AtMost(name.Length, 100, nameof(name));
+ ///
+ /// Adds a choice to the current option.
+ ///
+ /// The name of the choice.
+ /// The value of the choice.
+ /// The current builder.
+ public SlashCommandOptionBuilder AddChoice(string name, string value)
+ {
+ return AddChoiceInternal(name, value);
+ }
- Choices.Add(new ApplicationCommandOptionChoiceProperties
- {
- Name = name,
- Value = value
- });
+ ///
+ /// Adds a choice to the current option.
+ ///
+ /// The name of the choice.
+ /// The value of the choice.
+ /// The current builder.
+ public SlashCommandOptionBuilder AddChoice(string name, double value)
+ {
+ return AddChoiceInternal(name, value);
+ }
- return this;
+ ///
+ /// Adds a choice to the current option.
+ ///
+ /// The name of the choice.
+ /// The value of the choice.
+ /// The current builder.
+ public SlashCommandOptionBuilder AddChoice(string name, float value)
+ {
+ return AddChoiceInternal(name, value);
}
///
@@ -495,7 +501,12 @@ namespace Discord
/// The name of the choice.
/// The value of the choice.
/// The current builder.
- public SlashCommandOptionBuilder AddChoice(string name, string value)
+ public SlashCommandOptionBuilder AddChoice(string name, long value)
+ {
+ return AddChoiceInternal(name, value);
+ }
+
+ private SlashCommandOptionBuilder AddChoiceInternal(string name, object value)
{
Choices ??= new List();
@@ -508,8 +519,11 @@ namespace Discord
Preconditions.AtLeast(name.Length, 1, nameof(name));
Preconditions.AtMost(name.Length, 100, nameof(name));
- Preconditions.AtLeast(value.Length, 1, nameof(value));
- Preconditions.AtMost(value.Length, 100, nameof(value));
+ if (value is string str)
+ {
+ Preconditions.AtLeast(str.Length, 1, nameof(value));
+ Preconditions.AtMost(str.Length, 100, nameof(value));
+ }
Choices.Add(new ApplicationCommandOptionChoiceProperties
{
@@ -564,7 +578,7 @@ namespace Discord
/// The current builder.
public SlashCommandOptionBuilder WithRequired(bool value)
{
- Required = value;
+ IsRequired = value;
return this;
}
@@ -575,7 +589,7 @@ namespace Discord
/// The current builder.
public SlashCommandOptionBuilder WithDefault(bool value)
{
- Default = value;
+ IsDefault = value;
return this;
}
@@ -586,7 +600,7 @@ namespace Discord
/// The current builder.
public SlashCommandOptionBuilder WithAutocomplete(bool value)
{
- Autocomplete = value;
+ IsAutocomplete = value;
return this;
}
@@ -600,7 +614,7 @@ namespace Discord
MinValue = value;
return this;
}
-
+
///
/// Sets the current builders max value field.
///
diff --git a/src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandProperties.cs b/src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandProperties.cs
index 6f320ffeb..20ba2868f 100644
--- a/src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandProperties.cs
+++ b/src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandProperties.cs
@@ -3,13 +3,14 @@ using System.Collections.Generic;
namespace Discord
{
///
- /// A class used to create slash commands.
+ /// Represents a class used to create slash commands.
///
public class SlashCommandProperties : ApplicationCommandProperties
{
internal override ApplicationCommandType Type => ApplicationCommandType.Slash;
+
///
- /// The description of this command.
+ /// Gets or sets the discription of this command.
///
public Optional Description { get; set; }
diff --git a/src/Discord.Net.Rest/API/Common/ApplicationCommandOption.cs b/src/Discord.Net.Rest/API/Common/ApplicationCommandOption.cs
index b282f71bb..1207df282 100644
--- a/src/Discord.Net.Rest/API/Common/ApplicationCommandOption.cs
+++ b/src/Discord.Net.Rest/API/Common/ApplicationCommandOption.cs
@@ -71,9 +71,9 @@ namespace Discord.API
Options = option.Options?.Select(x => new ApplicationCommandOption(x)).ToArray() ?? Optional.Unspecified;
- Required = option.Required ?? Optional.Unspecified;
+ Required = option.IsRequired ?? Optional.Unspecified;
- Default = option.Default ?? Optional.Unspecified;
+ Default = option.IsDefault ?? Optional.Unspecified;
MinValue = option.MinValue ?? Optional.Unspecified;
MaxValue = option.MaxValue ?? Optional.Unspecified;
@@ -82,7 +82,7 @@ namespace Discord.API
Name = option.Name;
Type = option.Type;
Description = option.Description;
- Autocomplete = option.Autocomplete;
+ Autocomplete = option.IsAutocomplete;
}
}
}
diff --git a/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs b/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs
index 44ee7ac22..7cfc6a2ec 100644
--- a/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs
+++ b/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs
@@ -81,8 +81,8 @@ namespace Discord.Rest
{
Name = arg.Name.Value,
Type = arg.Type,
- DefaultPermission = arg.DefaultPermission.IsSpecified
- ? arg.DefaultPermission.Value
+ DefaultPermission = arg.IsDefaultPermission.IsSpecified
+ ? arg.IsDefaultPermission.Value
: Optional.Unspecified
};
@@ -115,8 +115,8 @@ namespace Discord.Rest
{
Name = arg.Name.Value,
Type = arg.Type,
- DefaultPermission = arg.DefaultPermission.IsSpecified
- ? arg.DefaultPermission.Value
+ DefaultPermission = arg.IsDefaultPermission.IsSpecified
+ ? arg.IsDefaultPermission.Value
: Optional.Unspecified
};
@@ -152,8 +152,8 @@ namespace Discord.Rest
{
Name = arg.Name.Value,
Type = arg.Type,
- DefaultPermission = arg.DefaultPermission.IsSpecified
- ? arg.DefaultPermission.Value
+ DefaultPermission = arg.IsDefaultPermission.IsSpecified
+ ? arg.IsDefaultPermission.Value
: Optional.Unspecified
};
@@ -212,8 +212,8 @@ namespace Discord.Rest
var model = new ModifyApplicationCommandParams
{
Name = args.Name,
- DefaultPermission = args.DefaultPermission.IsSpecified
- ? args.DefaultPermission.Value
+ DefaultPermission = args.IsDefaultPermission.IsSpecified
+ ? args.IsDefaultPermission.Value
: Optional.Unspecified
};
@@ -266,8 +266,8 @@ namespace Discord.Rest
{
Name = arg.Name.Value,
Type = arg.Type,
- DefaultPermission = arg.DefaultPermission.IsSpecified
- ? arg.DefaultPermission.Value
+ DefaultPermission = arg.IsDefaultPermission.IsSpecified
+ ? arg.IsDefaultPermission.Value
: Optional.Unspecified
};
@@ -299,8 +299,8 @@ namespace Discord.Rest
var model = new ModifyApplicationCommandParams
{
Name = arg.Name,
- DefaultPermission = arg.DefaultPermission.IsSpecified
- ? arg.DefaultPermission.Value
+ DefaultPermission = arg.IsDefaultPermission.IsSpecified
+ ? arg.IsDefaultPermission.Value
: Optional.Unspecified
};