Vencord/src/plugins/index.ts

28 lines
912 B
TypeScript
Raw Normal View History

2022-08-29 14:27:47 -04:00
import Plugins from "plugins";
2022-08-30 22:07:16 -04:00
import { Settings } from "../api/settings";
2022-08-29 14:27:47 -04:00
import Logger from "../utils/logger";
import { Patch } from "../utils/types";
2022-08-29 12:11:44 -04:00
2022-08-29 14:27:47 -04:00
const logger = new Logger("PluginManager", "#a6d189");
export const plugins = Plugins;
export const patches = [] as Patch[];
2022-08-30 22:07:16 -04:00
for (const plugin of Plugins) if (plugin.patches && Settings.plugins[plugin.name].enabled) {
2022-08-29 14:27:47 -04:00
for (const patch of plugin.patches) {
patch.plugin = plugin.name;
if (!Array.isArray(patch.replacement)) patch.replacement = [patch.replacement];
patches.push(patch);
}
}
export function startAll() {
2022-08-30 22:07:16 -04:00
for (const plugin of plugins) if (plugin.start && Settings.plugins[plugin.name].enabled) {
2022-08-29 14:27:47 -04:00
try {
logger.info("Starting plugin", plugin.name);
plugin.start();
} catch (err) {
logger.error("Failed to start plugin", plugin.name, err);
}
}
}