Plugin
Table of Contents
Class Definition
export abstract class Plugin {}
Properties
Property Type Description namestring The name of the plugin.
Constructor
new Plugin(name: string)
Parameter Type Description Optional namestring The name of the plugin.
Methods
load()
load(manager: Manager): voidLoad the plugin.
Parameter Type Description managerManagerManager class
unload()
unload(manager: Manager): voidUnload the plugin.
Parameter Type Description managerManagerManager class
Example usage
- Using plugins
- Writing plugins
const { Manager } = require("magmastream");
const MyPlugin = require("my-magmastream-plugin");
const manager = new Manager({
...ManagerOptions,
plugins: [new MyPlugin()],
});
import { Plugin, Manager } from "magmastream";
export class MyPlugin extends Plugin {
private options: Record<string, unknown>;
constructor(options: Record<string, unknown>) {
super("MyPlugin"); // Required: pass the plugin name to base constructor
this.options = options;
}
load(manager: Manager): void {
console.log(`[MyPlugin] Loaded with options:`, this.options);
// Attach event listeners, modify behavior, etc.
}
unload(manager: Manager): void {
console.log("[MyPlugin] Unloaded");
// Cleanup listeners, free resources, etc.
}
}