Try ChatCommandManager.ProcessCommand instead

This commit is contained in:
Claude
2025-11-23 19:17:37 +00:00
parent 9bd4ab35c5
commit 1ee6f45f70

View File

@@ -13,17 +13,18 @@ public class BotCommandMod : IModApi
}
}
[HarmonyPatch(typeof(GameManager), "ChatMessage")]
public class ChatMessagePatch
[HarmonyPatch(typeof(ChatCommandManager), "ProcessCommand")]
public class ChatCommandPatch
{
static bool Prefix(ClientInfo _cInfo, EChatType _type, string _msg, string _playerName)
static bool Prefix(ChatCommandManager __instance, string _chatText, ClientInfo _cInfo)
{
if (_msg != null && _msg.StartsWith("/bot "))
if (_chatText != null && _chatText.StartsWith("/bot "))
{
string playerName = _cInfo != null ? _cInfo.playerName : "Server";
Console.WriteLine($"[Bot] {playerName}: {_msg}");
Console.WriteLine($"[Bot] {playerName}: {_chatText}");
return false;
}
return true;
}
}