|
|
@@ -46,12 +46,12 @@ namespace Discord.WebSocket |
|
|
|
|
|
|
|
internal SocketAutocompleteInteractionData(DataModel model) |
|
|
|
{ |
|
|
|
var options = model.Options.Select(x => new AutocompleteOption(x.Type, x.Name, x.Value, x.Focused)); |
|
|
|
var options = model.Options.SelectMany(x => GetOptions(x)); |
|
|
|
|
|
|
|
Current = options.FirstOrDefault(x => x.Focused); |
|
|
|
Options = options.ToImmutableArray(); |
|
|
|
|
|
|
|
if (Options?.Count == 1 && Current == null) |
|
|
|
if (options != null && options.Count() == 1 && Current == null) |
|
|
|
Current = Options.FirstOrDefault(); |
|
|
|
|
|
|
|
CommandName = model.Name; |
|
|
@@ -59,5 +59,21 @@ namespace Discord.WebSocket |
|
|
|
Type = model.Type; |
|
|
|
Version = model.Version; |
|
|
|
} |
|
|
|
|
|
|
|
private List<AutocompleteOption> GetOptions(API.AutocompleteInteractionDataOption model) |
|
|
|
{ |
|
|
|
List<AutocompleteOption> options = new List<AutocompleteOption>(); |
|
|
|
|
|
|
|
if (model.Options.IsSpecified) |
|
|
|
{ |
|
|
|
options.AddRange(model.Options.Value.SelectMany(x => GetOptions(x))); |
|
|
|
} |
|
|
|
else if(model.Focused.IsSpecified) |
|
|
|
{ |
|
|
|
options.Add(new AutocompleteOption(model.Type, model.Name, model.Value, model.Focused.Value)); |
|
|
|
} |
|
|
|
|
|
|
|
return options; |
|
|
|
} |
|
|
|
} |
|
|
|
} |