From b1037edea139c3a8a674e0d1f792fc310abf07d7 Mon Sep 17 00:00:00 2001 From: GRZ4NA Date: Sun, 8 Aug 2021 02:02:30 +0200 Subject: [PATCH] removing unused params --- src/CommandManager.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/CommandManager.ts b/src/CommandManager.ts index b261677..4cea283 100644 --- a/src/CommandManager.ts +++ b/src/CommandManager.ts @@ -194,6 +194,7 @@ export class CommandManager { return null; } } + fetchFromInteraction( interaction: CommandInteraction ): CommandMessageStructure | null { @@ -218,8 +219,17 @@ export class CommandManager { } const parameters: InputParameter[] = []; cmd.parameters.map((p, i) => { - if (!p.optional && !paramsList[i]) { + const inputParam = paramsList[i]; + if (!p.optional && !inputParam) { throw new MissingParameterError(p); + } else if ( + p.optional && + (!inputParam || + inputParam == "" || + inputParam == "_" || + inputParam == " ") + ) { + return; } switch (p.type) { case "string": @@ -255,6 +265,8 @@ export class CommandManager { const inputParam = paramsList.find((d) => d.name == p.name); if (!p.optional && !inputParam) { throw new MissingParameterError(p); + } else if (p.optional && !inputParam) { + return; } switch (p.type) { case "string":