Add format arg for classify-expressions

85773ace79b3c9484e8351157894baa0d5ad74f3

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

1 files changed, +20 -1Ignore whitespace
public/scripts/extensions/expressions/index.js+20 -1
@@ -2122,7 +2122,26 @@ function migrateSettings() {
2122 SlashCommandParser.addCommandObject(SlashCommand.fromProps({2122 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
2123 name: 'classify-expressions',2123 name: 'classify-expressions',
2124 aliases: ['expressions'],2124 aliases: ['expressions'],
2125 callback: async () => (await getExpressionsList()).join(', '),2125 callback: async (args) => {
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 ],
2126 returns: 'The comma-separated list of available expressions, including custom expressions.',2145 returns: 'The comma-separated list of available expressions, including custom expressions.',
2127 helpString: 'Returns a list of available expressions, including custom expressions.',2146 helpString: 'Returns a list of available expressions, including custom expressions.',
2128 }));2147 }));