From 6d17f44f9b16fb78abf8a5689b63c88550b9b1a8 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Sat, 13 Aug 2022 12:22:26 +0200 Subject: Plugins finally load! --- src/util/plugin/Plugin.ts | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'src/util/plugin/Plugin.ts') diff --git a/src/util/plugin/Plugin.ts b/src/util/plugin/Plugin.ts index 1c86a006..0fb1732f 100644 --- a/src/util/plugin/Plugin.ts +++ b/src/util/plugin/Plugin.ts @@ -1,5 +1,5 @@ import EventEmitter from "events"; -import { TypedEventEmitter } from "@fosscord/util"; +import { PluginLoadedEventArgs, TypedEventEmitter } from "@fosscord/util"; type PluginEvents = { error: (error: Error | unknown) => void; @@ -7,14 +7,31 @@ type PluginEvents = { }; //this doesnt work, check later: - //(EventEmitter as new () => TypedEventEmitter) { -export class Plugin extends EventEmitter { - private _untypedOn = this.on - private _untypedEmit = this.emit - public on = (event: K, listener: PluginEvents[K]): this => this._untypedOn(event, listener) - public emit = (event: K, ...args: Parameters): boolean => this._untypedEmit(event, ...args) - - async init() { + //EventEmitter as new () => TypedEventEmitter +export class Plugin { + /** + * Path the plugin resides in. + * + * @type {string} + * @memberof Plugin + */ + pluginPath: string; + /** + * + * + * @memberof Plugin + */ + async initConfig() { // insert default config into database? + console.log("did you forget to implement initConfig?"); + } + /** + * + * + * @param {PluginLoadedEventArgs} args Info about plugin environment + * @memberof Plugin + */ + onPluginLoaded?(args?: PluginLoadedEventArgs) { + } } -- cgit 1.5.1