From cb9f96287bd138f49d6c374b826f134d8bdb4aac Mon Sep 17 00:00:00 2001 From: "[Cursors]" <65373746+cursorsdottsx@users.noreply.github.com> Date: Wed, 17 Feb 2021 09:31:03 -0600 Subject: [PATCH 1/2] cooldown or globalCooldown, not both With this interface hierarchy, TypeScript enforces that you can have cooldown or globalCooldown, but not both. --- src/interfaces/ICommand.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/interfaces/ICommand.ts b/src/interfaces/ICommand.ts index 432ab70..861b62c 100644 --- a/src/interfaces/ICommand.ts +++ b/src/interfaces/ICommand.ts @@ -1,4 +1,4 @@ -export default interface ICommand { +interface BaseCommand { names: string[] | string category: string minArgs?: number @@ -9,10 +9,20 @@ export default interface ICommand { syntax?: string requiredPermissions?: string[] callback?: Function - cooldown?: string - globalCooldown?: string ownerOnly?: boolean hidden?: boolean guildOnly?: boolean testOnly?: boolean } + +interface BaseCommandWithCooldown extends BaseCommand { + cooldown?: number +} + +interface BaseCommandWithCooldown extends BaseCommand { + globalCooldown?: number +} + +type ICommand = BaseCommandWithCooldown | BaseCommandWithGlobalCooldown + +export default ICommand From a050312fad7e39bad5fd560d1c7a9a7a6dd4b9fc Mon Sep 17 00:00:00 2001 From: "[Cursors]" <65373746+cursorsdottsx@users.noreply.github.com> Date: Wed, 17 Feb 2021 09:34:11 -0600 Subject: [PATCH 2/2] Update ICommand.ts --- src/interfaces/ICommand.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/interfaces/ICommand.ts b/src/interfaces/ICommand.ts index 861b62c..279551b 100644 --- a/src/interfaces/ICommand.ts +++ b/src/interfaces/ICommand.ts @@ -16,11 +16,11 @@ interface BaseCommand { } interface BaseCommandWithCooldown extends BaseCommand { - cooldown?: number + cooldown?: string } interface BaseCommandWithCooldown extends BaseCommand { - globalCooldown?: number + globalCooldown?: string } type ICommand = BaseCommandWithCooldown | BaseCommandWithGlobalCooldown