From 9bc4a92bf4be90499ee0aa9cba74c8de54dd1b4b Mon Sep 17 00:00:00 2001 From: Mike Donnalley Date: Wed, 11 Jan 2023 11:25:43 -0700 Subject: [PATCH] feat: add forwards compatibility for v2 args (#587) --- src/config/config.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/config/config.ts b/src/config/config.ts index 6ca1e573f..eeb6cc1a8 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -7,7 +7,7 @@ import {format} from 'util' import {Options, Plugin as IPlugin} from '../interfaces/plugin' import {Config as IConfig, ArchTypes, PlatformTypes, LoadOptions} from '../interfaces/config' -import {Command, CompletableOptionFlag, Hook, Hooks, PJSON, Topic} from '../interfaces' +import {ArgInput, Command, CompletableOptionFlag, Hook, Hooks, PJSON, Topic} from '../interfaces' import * as Plugin from './plugin' import {Debug, compact, loadJSON, collectUsableIds, getCommandIdPermutations} from './util' import {isProd} from '../util' @@ -786,7 +786,9 @@ export async function toCached(c: Command.Class, plugin?: IPlugin): Promise ({ + // v2 commands have args as an object, so we need to normalize it to an array for forwards compatibility + const normalized = (Array.isArray(c.args) ? c.args ?? [] : Object.values(c.args ?? {})) as ArgInput + const argsPromise = normalized.map(async a => ({ name: a.name, description: a.description, required: a.required,