From 14bef81e8f8c1124d3557f3cc8fb2229d7fbf101 Mon Sep 17 00:00:00 2001 From: Advaith Date: Fri, 16 Jul 2021 16:00:42 -0700 Subject: [PATCH 1/3] feat(ApplicationCommandOptionType): add NUMBER (10) --- src/util/Constants.js | 2 ++ typings/enums.d.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/src/util/Constants.js b/src/util/Constants.js index 9fbb1dfbe491..358396bd6a30 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -835,6 +835,7 @@ exports.OverwriteTypes = createEnum(['role', 'member']); * * CHANNEL * * ROLE * * MENTIONABLE + * * NUMBER * @typedef {string} ApplicationCommandOptionType */ exports.ApplicationCommandOptionTypes = createEnum([ @@ -848,6 +849,7 @@ exports.ApplicationCommandOptionTypes = createEnum([ 'CHANNEL', 'ROLE', 'MENTIONABLE', + 'NUMBER', ]); /** diff --git a/typings/enums.d.ts b/typings/enums.d.ts index fc14499a853c..c303a6474ea3 100644 --- a/typings/enums.d.ts +++ b/typings/enums.d.ts @@ -20,6 +20,7 @@ export enum ApplicationCommandOptionTypes { CHANNEL = 7, ROLE = 8, MENTIONABLE = 9, + NUMBER = 10, } export enum ApplicationCommandPermissionTypes { From c0052f9312cabf5fc070c77aca7b1c4fdeb4f2e2 Mon Sep 17 00:00:00 2001 From: Advaith Date: Fri, 23 Jul 2021 23:40:48 -0700 Subject: [PATCH 2/3] feat(CommandInteractionOptionResolver): add getNumber --- src/structures/CommandInteractionOptionResolver.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/structures/CommandInteractionOptionResolver.js b/src/structures/CommandInteractionOptionResolver.js index 348e091a6fd1..02cf5874c071 100644 --- a/src/structures/CommandInteractionOptionResolver.js +++ b/src/structures/CommandInteractionOptionResolver.js @@ -164,6 +164,17 @@ class CommandInteractionOptionResolver { return option?.value ?? null; } + /** + * Gets a number option. + * @param {string} name The name of the option. + * @param {boolean} [required=false] Whether to throw an error if the option is not found. + * @returns {?number} The value of the option, or null if not set and not required. + */ + getNumber(name, required = false) { + const option = this._getTypedOption(name, 'NUMBER', ['value'], required); + return option?.value ?? null; + } + /** * Gets a user option. * @param {string} name The name of the option. From 79696166e5423cb7fbb518056dfd68997f1eb6ba Mon Sep 17 00:00:00 2001 From: Advaith Date: Sat, 24 Jul 2021 19:38:05 -0700 Subject: [PATCH 3/3] types(CommandInteractionOptionResolver): add getNumber --- typings/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/typings/index.d.ts b/typings/index.d.ts index 5b85087b1f4f..05cdfec7c5e3 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -460,6 +460,8 @@ export class CommandInteractionOptionResolver { public getString(name: string, required?: boolean): string | null; public getInteger(name: string, required: true): number; public getInteger(name: string, required?: boolean): number | null; + public getNumber(name: string, required: true): number; + public getNumber(name: string, required?: boolean): number | null; public getUser(name: string, required: true): NonNullable; public getUser(name: string, required?: boolean): NonNullable | null; public getMember(name: string, required: true): NonNullable;