From 85773ace79b3c9484e8351157894baa0d5ad74f3 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Thu, 5 Sep 2024 10:48:46 +0300 Subject: [PATCH] Add format arg for classify-expressions --- .../scripts/extensions/expressions/index.js | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/public/scripts/extensions/expressions/index.js b/public/scripts/extensions/expressions/index.js index e1dfe873f..b79acc2bb 100644 --- a/public/scripts/extensions/expressions/index.js +++ b/public/scripts/extensions/expressions/index.js @@ -2122,7 +2122,26 @@ function migrateSettings() { SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'classify-expressions', aliases: ['expressions'], - callback: async () => (await getExpressionsList()).join(', '), + callback: async (args) => { + const list = await getExpressionsList(); + switch (String(args.format).toLowerCase()) { + case 'json': + return JSON.stringify(list); + default: + return list.join(', '); + } + }, + namedArgumentList: [ + SlashCommandNamedArgument.fromProps({ + name: 'format', + description: 'The format to return the list in: comma-separated plain text or JSON array. Default is plain text.', + typeList: [ARGUMENT_TYPE.STRING], + enumList: [ + new SlashCommandEnumValue('plain', null, enumTypes.enum, ', '), + new SlashCommandEnumValue('json', null, enumTypes.enum, '[]'), + ], + }), + ], returns: 'The comma-separated list of available expressions, including custom expressions.', helpString: 'Returns a list of available expressions, including custom expressions.', }));