MCCTeam / Minecraft-Console-Client

Lightweight console for Minecraft chat and automated scripts
https://mccteam.github.io
Other
1.67k stars 402 forks source link

[question] how to use ChatBot.ChatBotCommand?or how to add a mcc command #2764

Open moran0710 opened 4 months ago

moran0710 commented 4 months ago

hi i am learning to make a chatbot with mcc. i found ChatBotCommand in chatbot.cs ,but i dont know how to use it. Please tell me how to use this class,or other way to register a command,thanks a lot.

My attempt is as follows

using MinecraftClient.Scripting;

namespace MinecraftClient.ChatBots;

public class MyBot : ChatBot
{
    public override void Initialize()
    {
        base.Initialize();

        new ChatBotCommand("test", "print a test message", "", new CommandRunner(RunTest));//or maybe i need pass this object into a registration method?
        LogToConsole("Bot Loaded");  // this message can be printed
    }

    public string RunTest(string command, string[] args)
    {
        LogToConsole("it work!");
        return "end";
    }
}

and it dosent work ;(