Add format arg for classify-expressions

85773ace79b3c9484e8351157894baa0d5ad74f3

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +20 -1Showing whitespace changes
public/scripts/extensions/expressions/index.js+20 -1
@@ -2122,7 +2122,26 @@ function migrateSettings() {
21222122 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
21232123 name: 'classify-expressions',
21242124 aliases: ['expressions'],
21252125 callback: async (args) => (await getExpressionsList()).join(', '),{
2126+ const list = await getExpressionsList();
2127+ switch (String(args.format).toLowerCase()) {
2128+ case 'json':
2129+ return JSON.stringify(list);
2130+ default:
2131+ return list.join(', ');
2132+ }
2133+ },
2134+ namedArgumentList: [
2135+ SlashCommandNamedArgument.fromProps({
2136+ name: 'format',
2137+ description: 'The format to return the list in: comma-separated plain text or JSON array. Default is plain text.',
2138+ typeList: [ARGUMENT_TYPE.STRING],
2139+ enumList: [
2140+ new SlashCommandEnumValue('plain', null, enumTypes.enum, ', '),
2141+ new SlashCommandEnumValue('json', null, enumTypes.enum, '[]'),
2142+ ],
2143+ }),
2144+ ],
21262145 returns: 'The comma-separated list of available expressions, including custom expressions.',
21272146 helpString: 'Returns a list of available expressions, including custom expressions.',
21282147 }));