Vencord/src/plugins/index.ts

27 lines
786 B
TypeScript
Raw Normal View History

2022-08-29 18:27:47 +00:00
import Plugins from "plugins";
import Logger from "../utils/logger";
import { Patch } from "../utils/types";
2022-08-29 16:11:44 +00:00
2022-08-29 18:27:47 +00:00
const logger = new Logger("PluginManager", "#a6d189");
export const plugins = Plugins;
export const patches = [] as Patch[];
for (const plugin of Plugins) if (plugin.patches) {
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() {
for (const plugin of plugins) if (plugin.start) {
try {
logger.info("Starting plugin", plugin.name);
plugin.start();
} catch (err) {
logger.error("Failed to start plugin", plugin.name, err);
}
}
}