Add color arg to /echo for custom color
| @@ -772,11 +772,6 @@ export function initDefaultSlashCommands() { | |||
| 772 | ], | 772 | ], |
| 773 | }), | 773 | }), |
| 774 | SlashCommandNamedArgument.fromProps({ | 774 | SlashCommandNamedArgument.fromProps({ |
| 775 | name: 'cssClass', | ||
| 776 | description: 'additional css class to add to the toast message (e.g. for custom styling)', | ||
| 777 | typeList: [ARGUMENT_TYPE.STRING], | ||
| 778 | }), | ||
| 779 | SlashCommandNamedArgument.fromProps({ | ||
| 780 | name: 'timeout', | 775 | name: 'timeout', |
| 781 | description: 'time in milliseconds to display the toast message. Set this and \'extendedTimeout\' to 0 to show indefinitely until dismissed.', | 776 | description: 'time in milliseconds to display the toast message. Set this and \'extendedTimeout\' to 0 to show indefinitely until dismissed.', |
| 782 | typeList: [ARGUMENT_TYPE.NUMBER], | 777 | typeList: [ARGUMENT_TYPE.NUMBER], |
| @@ -802,6 +797,15 @@ export function initDefaultSlashCommands() { | |||
| 802 | defaultValue: 'false', | 797 | defaultValue: 'false', |
| 803 | enumList: commonEnumProviders.boolean('trueFalse')(), | 798 | enumList: commonEnumProviders.boolean('trueFalse')(), |
| 804 | }), | 799 | }), |
| 800 | SlashCommandNamedArgument.fromProps({ | ||
| 801 | name: 'cssClass', | ||
| 802 | description: 'additional css class to add to the toast message (e.g. for custom styling)', | ||
| 803 | typeList: [ARGUMENT_TYPE.STRING], | ||
| 804 | }), | ||
| 805 | SlashCommandNamedArgument.fromProps({ | ||
| 806 | name: 'color', | ||
| 807 | description: 'custom CSS color of the toast message. Accepts all valid CSS color values (e.g. \'red\', \'#FF0000\', \'rgb(255, 0, 0)\').<br />>Can be more customizable with the \'cssClass\' argument and custom classes.', | ||
| 808 | }) | ||
| 805 | ], | 809 | ], |
| 806 | unnamedArgumentList: [ | 810 | unnamedArgumentList: [ |
| 807 | new SlashCommandArgument( | 811 | new SlashCommandArgument( |
| @@ -2186,7 +2190,7 @@ async function generateCallback(args, value) { | |||
| 2186 | 2190 | ||
| 2187 | /** | 2191 | /** |
| 2188 | * | 2192 | * |
| 2189 | * @param {{title?: string, severity?: string, cssClass?: string, timeout?: string, extendedTimeout?: string, preventDuplicates?: string, awaitDismissal?: string}} args - named arguments from the slash command | 2193 | * @param {{title?: string, severity?: string, timeout?: string, extendedTimeout?: string, preventDuplicates?: string, awaitDismissal?: string, cssClass?: string, color?: string}} args - named arguments from the slash command |
| 2190 | * @param {string} value - The string to echo (unnamed argument from the slash command) | 2194 | * @param {string} value - The string to echo (unnamed argument from the slash command) |
| 2191 | * @returns {Promise<string>} The text that was echoed | 2195 | * @returns {Promise<string>} The text that was echoed |
| 2192 | */ | 2196 | */ |
| @@ -2226,22 +2230,27 @@ async function echoCallback(args, value) { | |||
| 2226 | options.toastClass = args.cssClass; | 2230 | options.toastClass = args.cssClass; |
| 2227 | } | 2231 | } |
| 2228 | 2232 | ||
| 2233 | let toast; | ||
| 2229 | switch (severity) { | 2234 | switch (severity) { |
| 2230 | case 'error': | 2235 | case 'error': |
| 2231 | toastr.error(value, title, options); | 2236 | toast = toastr.error(value, title, options); |
| 2232 | break; | 2237 | break; |
| 2233 | case 'warning': | 2238 | case 'warning': |
| 2234 | toastr.warning(value, title, options); | 2239 | toast = toastr.warning(value, title, options); |
| 2235 | break; | 2240 | break; |
| 2236 | case 'success': | 2241 | case 'success': |
| 2237 | toastr.success(value, title, options); | 2242 | toast = toastr.success(value, title, options); |
| 2238 | break; | 2243 | break; |
| 2239 | case 'info': | 2244 | case 'info': |
| 2240 | default: | 2245 | default: |
| 2241 | toastr.info(value, title, options); | 2246 | toast = toastr.info(value, title, options); |
| 2242 | break; | 2247 | break; |
| 2243 | } | 2248 | } |
| 2244 | 2249 | ||
| 2250 | if (args.color) { | ||
| 2251 | toast.css('background-color', args.color); | ||
| 2252 | } | ||
| 2253 | |||
| 2245 | if (awaitDismissal) { | 2254 | if (awaitDismissal) { |
| 2246 | return new Promise((resolve) => { | 2255 | return new Promise((resolve) => { |
| 2247 | resolveToastDismissal = resolve; | 2256 | resolveToastDismissal = resolve; |