fix(minecraft): announce giveUp cooldown to chat with reason when bot gives up

Add try-catch wrapped bot.chat call in executeGiveUpAction to broadcast "[debug] Giving up for {cooldownSeconds}s: {reason}" message, log warning on chat failure
This commit is contained in:
Rin
2026-02-18 11:14:42 +08:00
committed by Neko Ayaka
parent 7d4a0f1224
commit 604167c93e
@@ -303,6 +303,14 @@ export class Brain {
const cooldownSeconds = Number.isFinite(secondsRaw) ? Math.min(600, Math.max(10, Math.floor(secondsRaw))) : 45
this.giveUpUntil = Date.now() + cooldownSeconds * 1000
this.giveUpReason = typeof action.params?.reason === 'string' ? action.params.reason : undefined
try {
const reason = this.giveUpReason ? `: ${this.giveUpReason}` : ''
bot.bot.chat(`[debug] Giving up for ${cooldownSeconds}s${reason}`)
}
catch (err) {
this.deps.logger.withError(err as Error).warn('Brain: Failed to announce giveUp to chat')
}
}
if (action.tool === 'chat' && action.params?.feedback === true) {