From 41517582a77620f157ae4e06bef1b7f07e38e6b2 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 23 Nov 2025 19:20:52 +0000 Subject: [PATCH] Add reflection to discover available Chat methods --- Harmony/BotCommandPatch.cs | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/Harmony/BotCommandPatch.cs b/Harmony/BotCommandPatch.cs index 8f1d70b..1e49e2a 100644 --- a/Harmony/BotCommandPatch.cs +++ b/Harmony/BotCommandPatch.cs @@ -1,30 +1,27 @@ using HarmonyLib; using System.Reflection; using System; +using System.Linq; public class BotCommandMod : IModApi { public void InitMod(Mod _modInstance) { Console.WriteLine("[BotCommandMod] Loading"); - var harmony = new Harmony("com.botcommand.mod"); - harmony.PatchAll(Assembly.GetExecutingAssembly()); + + // List all GameManager methods containing "Chat" + var gmType = typeof(GameManager); + Console.WriteLine("[BotCommandMod] GameManager methods with 'Chat':"); + foreach (var method in gmType.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static)) + { + if (method.Name.Contains("Chat")) + { + var parameters = string.Join(", ", method.GetParameters().Select(p => p.ParameterType.Name + " " + p.Name)); + Console.WriteLine($" {method.Name}({parameters})"); + } + } + Console.WriteLine("[BotCommandMod] Loaded"); } } -[HarmonyPatch(typeof(ChatCommandManager), "ProcessCommand")] -public class ChatCommandPatch -{ - static bool Prefix(ChatCommandManager __instance, string _chatText, ClientInfo _cInfo) - { - if (_chatText != null && _chatText.StartsWith("/bot ")) - { - string playerName = _cInfo != null ? _cInfo.playerName : "Server"; - Console.WriteLine($"[Bot] {playerName}: {_chatText}"); - return false; - } - return true; - } -} -