Add cssClass arg to /echo

This commit is contained in:
Wolfsblvt 2024-09-06 18:46:35 +02:00
parent b83cfa07c9
commit c9ed91099f
1 changed files with 10 additions and 1 deletions

View File

@ -771,6 +771,11 @@ export function initDefaultSlashCommands() {
new SlashCommandEnumValue('success', 'success', enumTypes.enum, '✅'),
],
}),
SlashCommandNamedArgument.fromProps({
name: 'cssClass',
description: 'additional css class to add to the toast message (e.g. for custom styling)',
typeList: [ARGUMENT_TYPE.STRING],
}),
SlashCommandNamedArgument.fromProps({
name: 'timeout',
description: 'time in milliseconds to display the toast message. Set this and \'extendedTimeout\' to 0 to show indefinitely until dismissed.',
@ -2181,7 +2186,7 @@ async function generateCallback(args, value) {
/**
*
* @param {{title?: string, severity?: string, timeout?: string, extendedTimeout?: string, preventDuplicates?: string, awaitDismissal?: string}} args - named arguments from the slash command
* @param {{title?: string, severity?: string, cssClass?: string, timeout?: string, extendedTimeout?: string, preventDuplicates?: string, awaitDismissal?: string}} args - named arguments from the slash command
* @param {string} value - The string to echo (unnamed argument from the slash command)
* @returns {Promise<string>} The text that was echoed
*/
@ -2217,6 +2222,10 @@ async function echoCallback(args, value) {
options.onHidden = () => resolveToastDismissal(value);
}
if (args.cssClass) {
options.toastClass = args.cssClass;
}
switch (severity) {
case 'error':
toastr.error(value, title, options);