Add format arg for classify-expressions

This commit is contained in:
Cohee 2024-09-05 10:48:46 +03:00
parent b4ecba2a45
commit 85773ace79
1 changed files with 20 additions and 1 deletions

View File

@ -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.',
}));