-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Currently src/index.ts has a big switch statement for known commands. This won't scale as additional commands are added and command requests could come from different sources (e.g. Facebook messenger bots, web interface, etc).
The pattern here should be that we define a Command interface that different commands can implement and provide a registry function to add that command to the CommandRegistry. The following is a very rough interface and example.
interface McCommand {
run(args: string[]): Promise<void>;
}
class EchoCommand implements McCommand {
constructor(bot: mineflayer.Bot, mcmanus: McManus) {
...
}
run(args: string[]): Promise<void> {
this.bot.chat(args.join(" "));
return new Promise();
}
}
registryCommand(EchoCommand);We should support dependency injection so the right dependencies get passed to the constructor of the commands and we can support per command configs, client interfaces such as a sqlite connection, etc.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request