Files
factorio-clusterio/plugins/global_chat/control.js
T
Hornwitser 295cc7543a Reverse argument order for sendTo
It makes more sense to put the address first then have the large
structure to send as the second argument to sendTo.  The opposite order
was originally chosen to be similar to that of sendto in BSD sockets.
2023-07-27 00:24:24 +02:00

28 lines
812 B
JavaScript

"use strict";
const libPlugin = require("@clusterio/lib/plugin");
const { ChatEvent } = require("./messages");
const libCommand = require("@clusterio/lib/command");
const globalChatCommands = new libCommand.CommandTree({
name: "global-chat", description: "Global Chat plugin commands",
});
globalChatCommands.add(new libCommand.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 libPlugin.BaseControlPlugin {
async addCommands(rootCommand) {
rootCommand.add(globalChatCommands);
}
}
module.exports = {
ControlPlugin,
};