mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-11 23:04:52 +09:00
* .js to .ts * translate * update paths to dist/plugin * add "tsc --build" to prepare * use field main in package.json de find info * tsc --build need to append before webpack * update test and use for plugins package.main
21 lines
709 B
TypeScript
21 lines
709 B
TypeScript
import { BaseControlPlugin, CommandTree, Command } from "@clusterio/lib";
|
|
import { ChatEvent } from "./messages";
|
|
|
|
const globalChatCommands = new CommandTree({
|
|
name: "global-chat", description: "Global Chat plugin commands",
|
|
});
|
|
globalChatCommands.add(new Command({
|
|
definition: ["shout <message>", "Send message to all instances", (yargs) => {
|
|
yargs.positional("message", { describe: "message to send", type: "string" });
|
|
}],
|
|
handler: async function(args, control) {
|
|
await control.sendTo("allInstances", new ChatEvent("Console", args.message));
|
|
},
|
|
}));
|
|
|
|
export class ControlPlugin extends BaseControlPlugin {
|
|
async addCommands(rootCommand: CommandTree) {
|
|
rootCommand.add(globalChatCommands);
|
|
}
|
|
}
|