Developing A Plugin

This library allows developers to create their own plugins for rce.js so users can have a better experience using the library! This page shows you as a developer what you need to create a plugin.

Base Class

You will need to install rce.js as a dependency as you need to work with the RCEManager class, which you have access to.

npm install rce.js
import type { RCEManager } from "rce.js";

export class ExamplePlugin {
    private rce: RCEManager;

    public constructor() {}
    
    // The "init" method is mandatory for registering your plugin
    public init(rce: RCEManager) {
        this.rce = rce;
        (rce as any).example = this;
    }
    
    // You can now implement other methods as you wish!
    public test() {
        this.rce.logger.info("This is a test log!");
    }
}

From the above example, the user installing your plugin would use it like so:

import { RCEManager } from "rce.js";
import ExamplePlugin from "rce.js-example";

const rce = new RCEManager();
await rce.init({
    // AuthOptions
}, {
    // LoggerOptions
});

rce.registerPlugin("example", new ExamplePlugin());
rce.example.test(); // This will log "This is a test log!" to the console

Last updated