# Chat Command Based Extension

**PluginCore.cs**

```csharp
[Plugin(1, "Bot Viewer Extension Plugin", "Test plugin to showcase bot viewer possible extensions using chat command invocations.")]
public class PluginCore : IStartPlugin
{
    public override void OnLoad(int version, int subversion, int buildversion) { }
    public override PluginResponse OnEnable(IBotSettings botSettings) { return base.OnEnable(botSettings); }
}

public class ExampleChatHandler : IBotServerChatHandler {
    public override string Name { get; set; } = "test";
    public override string Description { get; set; } = "This is a test chat command handler for OQMineBot's bot server.";
    public override string[] RequiredArguments { get; set; } = {"none|all", "opt|opt2|opt3" };
    public override string[] OptionalArguments { get; set; } = { "greet|insult" };

    public override ChatHandlerResult Execute(IBotContext Context, IConnectedClient Client, IBotServerEvents Events, string[] arguments) {

        // Sanity checks.
        if (arguments.Length < 1) return new ChatHandlerResult(false, "Argument not found.");
        var argument = arguments[0].ToLower();
        if (argument != "none" && argument != "all") return new ChatHandlerResult(false, "Invalid argument.");

        /*
         * Execute command here.
         */

        return new ChatHandlerResult(true); // success
    }
}
```

<div align="left"><img src="/files/-M8NtJGQkyD--LDREIfR" alt="Result from running the example code."></div>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.minecraftbot.com/examples/botviewer-additions/chat-command-based-extension.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
