From cd87664d71f6eb4628b57fc3178e048f132b4d62 Mon Sep 17 00:00:00 2001 From: quin lynch Date: Thu, 30 Sep 2021 14:09:19 -0300 Subject: [PATCH] Add Autocomplete to SlashCommandOptionBuilder --- .../Slash Commands/SlashCommandBuilder.cs | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/Discord.Net.Core/Entities/Interactions/Slash Commands/SlashCommandBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/Slash Commands/SlashCommandBuilder.cs index 16855b818..ec0883981 100644 --- a/src/Discord.Net.Core/Entities/Interactions/Slash Commands/SlashCommandBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/Slash Commands/SlashCommandBuilder.cs @@ -208,20 +208,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. - ///// If this option is required for this command. - ///// If this option is the default option. - ///// The choices of this option. - ///// The current builder. - //public SlashCommandBuilder AddOption(string name, ApplicationCommandOptionType type, - // string description, bool required = true, bool isDefault = false, params ApplicationCommandOptionChoiceProperties[] choices) - // => AddOption(name, type, description, required, isDefault, null, choices); - /// /// Adds an option to the current slash command. /// @@ -400,7 +386,7 @@ namespace Discord /// The choices of this option. /// The current builder. public SlashCommandOptionBuilder AddOption(string name, ApplicationCommandOptionType type, - string description, bool? required = null, bool isDefault = false, List options = null, params ApplicationCommandOptionChoiceProperties[] choices) + string description, bool? required = null, bool isDefault = false, bool isAutocomplete = false, List options = null, params ApplicationCommandOptionChoiceProperties[] choices) { // Make sure the name matches the requirements from discord Preconditions.NotNullOrEmpty(name, nameof(name)); @@ -433,7 +419,8 @@ namespace Discord Default = isDefault, Options = options, Type = type, - Choices = choices != null ? new List(choices) : null + Choices = choices != null ? new List(choices) : null, + Autocomplete = isAutocomplete, }; return AddOption(option); @@ -567,6 +554,17 @@ namespace Discord return this; } + /// + /// Sets the current builders autocomplete field. + /// + /// The value to set. + /// The current builder. + public SlashCommandOptionBuilder WithAutocomplete(bool value) + { + Autocomplete = value; + return this; + } + /// /// Sets the current type of this builder. ///