(host: SlashCommandHost, parsed: ParsedSlashInput)
| 226 | * Returns true when it claimed the input. |
| 227 | */ |
| 228 | export function tryHandleDanceCommand(host: SlashCommandHost, parsed: ParsedSlashInput): boolean { |
| 229 | if (parsed.name !== 'dance') return false; |
| 230 | if (currentDanceController === undefined) return false; |
| 231 | |
| 232 | // The status line dims the whole message, which buried the command in the |
| 233 | // hint. Paint just the command in the brand color (bold) so it reads as a |
| 234 | // command; chalk nesting resumes the dim run right after it. |
| 235 | const cmd = (text: string): string => currentTheme.boldFg('primary', text); |
| 236 | |
| 237 | const sub = parsed.args.trim().toLowerCase(); |
| 238 | if (sub === 'off') { |
| 239 | currentDanceController.stop(); |
| 240 | } else if (sub === 'on') { |
| 241 | currentDanceController.start({ hold: true }); |
| 242 | host.showStatus(`Dancing — use ${cmd('/dance off')} to turn it off.`); |
| 243 | } else { |
| 244 | currentDanceController.start({ hold: false }); |
| 245 | host.showStatus(`Use ${cmd('/dance on')} to keep the rainbow on.`); |
| 246 | } |
| 247 | return true; |
| 248 | } |
no test coverage detected