(onDone, context, args)
| 331 | } |
| 332 | |
| 333 | export const call: LocalJSXCommandCall = async (onDone, context, args) => { |
| 334 | const config = getGlobalConfig() |
| 335 | const trimmedArgs = args?.trim() |
| 336 | |
| 337 | if (trimmedArgs === 'pet') { |
| 338 | const companion = getCompanion() |
| 339 | if (!companion) { |
| 340 | onDone('no companion yet · run /buddy first', { display: 'system' }) |
| 341 | return null |
| 342 | } |
| 343 | if (config.companionMuted === true) { |
| 344 | saveGlobalConfig(current => ({ |
| 345 | ...current, |
| 346 | companionMuted: false, |
| 347 | })) |
| 348 | } |
| 349 | context.setAppState(current => ({ |
| 350 | ...current, |
| 351 | companionPetAt: Date.now(), |
| 352 | })) |
| 353 | void firePetReaction(setReaction(context.setAppState)) |
| 354 | onDone(`petted ${companion.name}`, { display: 'system' }) |
| 355 | return null |
| 356 | } |
| 357 | |
| 358 | if (trimmedArgs === 'off') { |
| 359 | if (config.companionMuted !== true) { |
| 360 | saveGlobalConfig(current => ({ |
| 361 | ...current, |
| 362 | companionMuted: true, |
| 363 | })) |
| 364 | } |
| 365 | onDone('companion muted', { display: 'system' }) |
| 366 | return null |
| 367 | } |
| 368 | |
| 369 | if (trimmedArgs === 'on') { |
| 370 | if (config.companionMuted === true) { |
| 371 | saveGlobalConfig(current => ({ |
| 372 | ...current, |
| 373 | companionMuted: false, |
| 374 | })) |
| 375 | } |
| 376 | onDone('companion unmuted', { display: 'system' }) |
| 377 | return null |
| 378 | } |
| 379 | |
| 380 | if (config.companionMuted === true) { |
| 381 | saveGlobalConfig(current => ({ |
| 382 | ...current, |
| 383 | companionMuted: false, |
| 384 | })) |
| 385 | } |
| 386 | |
| 387 | const existingCompanion = getCompanion() |
| 388 | if (existingCompanion) { |
| 389 | return ( |
| 390 | <CompanionCard |
nothing calls this directly
no test coverage detected