Files
factorio-clusterio/plugins/global_chat/control.js
T
Hornwitser 24397b75cc Prefix clusterio/lib imports with lib
Use lib* prefix for the modules impored from the lib package to help
distinguish them more from ordinary variables.  Fix up the naming
convention for files to be consistently lowercase_underscore for
JavaScript files.
2020-10-23 21:22:43 +02:00

31 lines
823 B
JavaScript

"use strict";
const libPlugin = require("@clusterio/lib/plugin");
const info = require("./info");
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 info.messages.chat.send(control, {
instance_name: "Console",
content: args.message,
});
},
}));
class ControlPlugin extends libPlugin.BaseControlPlugin {
async addCommands(rootCommand) {
rootCommand.add(globalChatCommands);
}
}
module.exports = {
ControlPlugin,
};