From f60ccb766f30e7518bc348013b72f071f86ecbc6 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 31 Aug 2022 22:08:05 +0200 Subject: Add Plugin.start, make Settings actually start/stop plugins --- src/utils/logger.ts | 20 +++++++++++++------- src/utils/types.ts | 17 +++++++++-------- 2 files changed, 22 insertions(+), 15 deletions(-) (limited to 'src/utils') diff --git a/src/utils/logger.ts b/src/utils/logger.ts index be341ee..be32f2b 100644 --- a/src/utils/logger.ts +++ b/src/utils/logger.ts @@ -1,27 +1,33 @@ export default class Logger { constructor(public name: string, public color: string) { } - private _log(level: "log" | "error" | "warn" | "info" | "debug", args: any[]) { - console[level](`%c ${this.name} `, `background: ${this.color}; color: black; font-weight: bold`, ...args); + private _log(level: "log" | "error" | "warn" | "info" | "debug", levelColor: string, args: any[]) { + console[level]( + `%c Vencord %c %c ${this.name} `, + `background: ${levelColor}; color: black; font-weight: bold; border-radius: 5px;`, + "", + `background: ${this.color}; color: black; font-weight: bold; border-radius: 5px;` + , ...args + ); } public log(...args: any[]) { - this._log("log", args); + this._log("log", "#a6d189", args); } public info(...args: any[]) { - this._log("info", args); + this._log("info", "#a6d189", args); } public error(...args: any[]) { - this._log("error", args); + this._log("error", "#e78284", args); } public warn(...args: any[]) { - this._log("warn", args); + this._log("warn", "#e5c890", args); } public debug(...args: any[]) { - this._log("debug", args); + this._log("debug", "#eebebe", args); } } \ No newline at end of file diff --git a/src/utils/types.ts b/src/utils/types.ts index 520b506..810869c 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -1,5 +1,5 @@ // exists to export default definePlugin({...}) -export default function definePlugin(p: PluginDef) { +export default function definePlugin(p: PluginDef & Record) { return p; } @@ -14,17 +14,18 @@ export interface Patch { replacement: PatchReplacement | PatchReplacement[]; } -export interface Plugin { +export interface Plugin extends PluginDef { + patches?: Patch[]; + started: boolean; +} + +interface PluginDef { name: string; description: string; author: string; start?(): void; - patches?: Patch[]; + stop?(): void; + patches?: Omit[]; dependencies?: string[], required?: boolean; -} - -// @ts-ignore lole -interface PluginDef extends Plugin { - patches?: Omit[]; } \ No newline at end of file -- cgit