-
Notifications
You must be signed in to change notification settings - Fork 23
Plugins
Making plugins is very simple and you have 2 options:
The javascript plugin api supports most of ES6
Global Variables
server.close
(function<code?: number>) - closes the server
server.logger.info
(function<format: string, ...any>) - print something to the console with this format [<DATE> INFO]:
server.logger.debug
(function<format: string, ...any>) - print something to the console with this format [<DATE> DEBUG]:
. If the server isn't running with the -debug argument, the text will not be shown
server.logger.error
(function<format: string, ...any>) - print something to the console with this format [<DATE> ERROR]:
server.logger.warn
(function<format: string, ...any>) - print something to the console with this format [<DATE> WARN]:
server.logger.print
(function<format: string, ...any>) - print something to the console
server.commands.register
(function<cmd: Command>) - register (override) a command
server.commands.delete
(function<name: string>) - delete a command
server.commands.get
(function<name: string>:Command) - get a command with the specified name
server.commands.getAll
(function:Command[]) - get all commands
Plugin
(function) - register the plugin
Plugin Example:
Plugin({
identifier: "com.oq.myplugin",
onLoad: () => {
server.logger.info("MYPLUGIN!!!!!!!!!!!!!!!!!!!!!!!!!!");
server.logger.warn("This plugin might be too cool for your server");
server.logger.error("Failed to find who asked");
server.logger.debug("Loading commands!!!!");
server.logger.print("Regular print.");
server.commands.register({
name: "command",
execute: (ctx) => {
ctx.Reply("hi");
},
});
},
});
Multi file plugins You can also make a plugin with multiple files, and here's how:
- Make a
plugin.json
file that contains the following text:
{
"rootFile": "index.js", // The root file of the plugin
"type": "javascript"
}
-
In your plugin files, you can use the
require
function. For example,const commands = require("commands.js")
-
To export stuff, you can use the
exports
variable. For example,exports = { commands: [] }