Initial pass at making slash commands respond as expectedpull/1923/head
| @@ -1,9 +1,5 @@ | |||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
| using System; | |||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Linq; | |||||
| using System.Text; | |||||
| using System.Threading.Tasks; | |||||
| namespace Discord.API | namespace Discord.API | ||||
| { | { | ||||
| @@ -16,6 +12,6 @@ namespace Discord.API | |||||
| public string Name { get; set; } | public string Name { get; set; } | ||||
| [JsonProperty("options")] | [JsonProperty("options")] | ||||
| public Optional<ApplicationCommandInteractionDataOption[]> Options { get; set; } | |||||
| public List<ApplicationCommandInteractionDataOption> Options { get; set; } = new(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,9 +1,5 @@ | |||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
| using System; | |||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Linq; | |||||
| using System.Text; | |||||
| using System.Threading.Tasks; | |||||
| namespace Discord.API | namespace Discord.API | ||||
| { | { | ||||
| @@ -16,6 +12,6 @@ namespace Discord.API | |||||
| public Optional<object> Value { get; set; } | public Optional<object> Value { get; set; } | ||||
| [JsonProperty("options")] | [JsonProperty("options")] | ||||
| public Optional<IEnumerable<ApplicationCommandInteractionDataOption>> Options { get; set; } | |||||
| public List<ApplicationCommandInteractionDataOption> Options { get; set; } = new(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,12 +1,10 @@ | |||||
| using Discord.Rest; | using Discord.Rest; | ||||
| using Newtonsoft.Json.Linq; | using Newtonsoft.Json.Linq; | ||||
| using System; | using System; | ||||
| using System.Collections.Generic; | |||||
| using System.Linq; | using System.Linq; | ||||
| using System.Text; | |||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
| using Model = Discord.API.Gateway.InteractionCreated; | |||||
| using DataModel = Discord.API.ApplicationCommandInteractionData; | using DataModel = Discord.API.ApplicationCommandInteractionData; | ||||
| using Model = Discord.API.Gateway.InteractionCreated; | |||||
| namespace Discord.WebSocket | namespace Discord.WebSocket | ||||
| { | { | ||||
| @@ -1,9 +1,6 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Collections.Immutable; | using System.Collections.Immutable; | ||||
| using System.Linq; | using System.Linq; | ||||
| using System.Text; | |||||
| using System.Threading.Tasks; | |||||
| using Model = Discord.API.ApplicationCommandInteractionData; | using Model = Discord.API.ApplicationCommandInteractionData; | ||||
| namespace Discord.WebSocket | namespace Discord.WebSocket | ||||
| @@ -14,7 +11,7 @@ namespace Discord.WebSocket | |||||
| public string Name { get; private set; } | public string Name { get; private set; } | ||||
| /// <summary> | /// <summary> | ||||
| /// The <see cref="SocketSlashCommandDataOption"/>'s recieved with this interaction. | |||||
| /// The <see cref="SocketSlashCommandDataOption"/>'s received with this interaction. | |||||
| /// </summary> | /// </summary> | ||||
| public IReadOnlyCollection<SocketSlashCommandDataOption> Options { get; private set; } | public IReadOnlyCollection<SocketSlashCommandDataOption> Options { get; private set; } | ||||
| @@ -33,8 +30,9 @@ namespace Discord.WebSocket | |||||
| internal void Update(Model model) | internal void Update(Model model) | ||||
| { | { | ||||
| this.Name = model.Name; | this.Name = model.Name; | ||||
| this.Options = model.Options.IsSpecified | |||||
| ? model.Options.Value.Select(x => new SocketSlashCommandDataOption(x, this.Discord)).ToImmutableArray() | |||||
| this.Options = model.Options.Any() | |||||
| ? model.Options.Select(x => new SocketSlashCommandDataOption(x, this.Discord)).ToImmutableArray() | |||||
| : null; | : null; | ||||
| } | } | ||||
| @@ -1,9 +1,6 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Collections.Immutable; | using System.Collections.Immutable; | ||||
| using System.Linq; | using System.Linq; | ||||
| using System.Text; | |||||
| using System.Threading.Tasks; | |||||
| using Model = Discord.API.ApplicationCommandInteractionDataOption; | using Model = Discord.API.ApplicationCommandInteractionDataOption; | ||||
| namespace Discord.WebSocket | namespace Discord.WebSocket | ||||
| @@ -20,7 +17,7 @@ namespace Discord.WebSocket | |||||
| public object Value { get; private set; } | public object Value { get; private set; } | ||||
| /// <summary> | /// <summary> | ||||
| /// The sub command options recieved for this sub command group. | |||||
| /// The sub command options received for this sub command group. | |||||
| /// </summary> | /// </summary> | ||||
| public IReadOnlyCollection<SocketSlashCommandDataOption> Options { get; private set; } | public IReadOnlyCollection<SocketSlashCommandDataOption> Options { get; private set; } | ||||
| @@ -33,8 +30,8 @@ namespace Discord.WebSocket | |||||
| this.Value = model.Value.IsSpecified ? model.Value.Value : null; | this.Value = model.Value.IsSpecified ? model.Value.Value : null; | ||||
| this.discord = discord; | this.discord = discord; | ||||
| this.Options = model.Options.IsSpecified | |||||
| ? model.Options.Value.Select(x => new SocketSlashCommandDataOption(x, discord)).ToImmutableArray() | |||||
| this.Options = model.Options.Any() | |||||
| ? model.Options.Select(x => new SocketSlashCommandDataOption(x, discord)).ToImmutableArray() | |||||
| : null; | : null; | ||||
| } | } | ||||