Files
factorio-clusterio/plugins/global_chat/control.js
T
Hornwitser bfe119eaa3 Flatten lib namespace
Move all functions and classes currently available through lib/name and
libName to be under a single flat namespace in lib.  This make
reorganising the lib namespace much simpler as the location of symbols
can move without breaking the consumers of lib.

The multi-entrypoint design was already problematic for the web plugin
system which couldn't effectively use it due to how webpack's shared
module system is awkward to set up with multiple entrypoints per package.
2023-07-28 16:03:29 +02:00

27 lines
753 B
JavaScript

"use strict";
const { BaseControlPlugin, CommandTree, Command } = require("@clusterio/lib");
const { ChatEvent } = require("./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));
},
}));
class ControlPlugin extends BaseControlPlugin {
async addCommands(rootCommand) {
rootCommand.add(globalChatCommands);
}
}
module.exports = {
ControlPlugin,
};