From b01c2981cd829e09610f3530edffdbbc5fc6df12 Mon Sep 17 00:00:00 2001 From: MrCakeSlayer <13650699+MrCakeSlayer@users.noreply.github.com> Date: Wed, 28 Jul 2021 08:20:53 -0400 Subject: [PATCH] =?UTF-8?q?Add=20new=20`NUMBER`=20option=20type=20(https:/?= =?UTF-8?q?/discord.com/developers/docs/int=E2=80=A6=20(#60)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add new `NUMBER` option type (https://discord.com/developers/docs/interactions/slash-commands#application-command-object-application-command-option-type) https://discord.com/developers/docs/interactions/slash-commands#application-command-object-application-command-option-type * Add number to SocketSlashCommandDataOption.cs --- .../Interactions/ApplicationCommandOptionType.cs | 7 ++++++- .../Slash Commands/SocketSlashCommandDataOption.cs | 10 +++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOptionType.cs b/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOptionType.cs index 18e383cef..a1b366e18 100644 --- a/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOptionType.cs +++ b/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOptionType.cs @@ -54,6 +54,11 @@ namespace Discord /// /// A or . /// - Mentionable = 9 + Mentionable = 9, + + /// + /// A . + /// + Number = 10 } } diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandDataOption.cs b/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandDataOption.cs index d62f1bf58..f33008cf3 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandDataOption.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandDataOption.cs @@ -96,7 +96,15 @@ namespace Discord.WebSocket { if (model.Value.Value is bool val) this.Value = val; - else if (bool.TryParse(model.Value.Value.ToString(), out var res)) + else if (bool.TryParse(model.Value.Value.ToString(), out bool res)) + this.Value = res; + } + break; + case ApplicationCommandOptionType.Number: + { + if (model.Value.Value is int val) + this.Value = val; + else if (double.TryParse(model.Value.Value.ToString(), out double res)) this.Value = res; } break;