Skip to content

Commit

Permalink
Add IsAutocomplete to rest command options (discord-net#368)
Browse files Browse the repository at this point in the history
  • Loading branch information
CottageDwellingCat authored Dec 11, 2021
1 parent b63c3b1 commit 60ac2ac
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public interface IApplicationCommandOption
/// </summary>
bool? IsRequired { get; }

/// <summary>
/// Gets whether or not the option has autocomplete enabled.
/// </summary>
bool? IsAutocomplete { get; }

/// <summary>
/// Gets the smallest number value the user can input.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public ApplicationCommandOption(IApplicationCommandOption cmd)
Default = cmd.IsDefault ?? Optional<bool>.Unspecified;
MinValue = cmd.MinValue ?? Optional<double>.Unspecified;
MaxValue = cmd.MaxValue ?? Optional<double>.Unspecified;
Autocomplete = cmd.IsAutocomplete ?? Optional<bool>.Unspecified;

Name = cmd.Name;
Type = cmd.Type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public class RestApplicationCommandOption : IApplicationCommandOption
/// <inheritdoc/>
public bool? IsRequired { get; private set; }

/// <inheritdoc/>
public bool? IsAutocomplete { get; private set; }

/// <inheritdoc/>
public double? MinValue { get; private set; }

Expand Down Expand Up @@ -74,6 +77,9 @@ internal void Update(Model model)
if (model.MaxValue.IsSpecified)
MaxValue = model.MaxValue.Value;

if (model.Autocomplete.IsSpecified)
IsAutocomplete = model.Autocomplete.Value;

Options = model.Options.IsSpecified
? model.Options.Value.Select(Create).ToImmutableArray()
: ImmutableArray.Create<RestApplicationCommandOption>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class SocketApplicationCommandOption : IApplicationCommandOption
/// <inheritdoc/>
public bool? IsRequired { get; private set; }

public bool? IsAutocomplete { get; private set; }

/// <inheritdoc/>
public double? MinValue { get; private set; }

Expand Down Expand Up @@ -68,6 +70,8 @@ internal void Update(Model model)

MaxValue = model.MaxValue.ToNullable();

IsAutocomplete = model.Autocomplete.ToNullable();

Choices = model.Choices.IsSpecified
? model.Choices.Value.Select(SocketApplicationCommandChoice.Create).ToImmutableArray()
: ImmutableArray.Create<SocketApplicationCommandChoice>();
Expand Down

0 comments on commit 60ac2ac

Please sign in to comment.