Fix Script bots accumulating on reconnect by unloading on disconnect

Script ChatBots were persisted in the static botsOnHold list across
reconnects. When ScriptScheduler triggered new scripts on login, the
old Script bots were still running, causing duplicate commands to be
sent simultaneously. This led to command spam and crashes.

Adding OnDisconnect to the Script ChatBot ensures scripts are removed
from the bots list before they can be saved to botsOnHold, preventing
accumulation of duplicate script instances on reconnect.
This commit is contained in:
copilot-swe-agent[bot] 2026-06-05 06:29:43 +00:00 committed by GitHub
parent 2b05b7420e
commit 8757533fb9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -149,6 +149,12 @@ namespace MinecraftClient.ChatBots
}
}
public override bool OnDisconnect(DisconnectReason reason, string message)
{
UnloadBot();
return false;
}
public override void Update()
{
if (csharp) //C# compiled script