aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorVendicated <vendicated@riseup.net>2022-08-29 20:27:47 +0200
committerVendicated <vendicated@riseup.net>2022-08-29 20:27:47 +0200
commitc39ff8f6481463a1700014ebd204f2b6189759a1 (patch)
treea5a4d1fe04a9d99029d480ec3f5a2ca2fb9c0b13 /src/plugins
parent1709ab61ef2138d350b3d45a3eba0d94d5adf0a1 (diff)
downloadVencord-c39ff8f6481463a1700014ebd204f2b6189759a1.tar.gz
Vencord-c39ff8f6481463a1700014ebd204f2b6189759a1.tar.bz2
Vencord-c39ff8f6481463a1700014ebd204f2b6189759a1.zip
More progress
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/bar.ts13
-rw-r--r--src/plugins/foo.ts13
-rw-r--r--src/plugins/index.ts28
3 files changed, 46 insertions, 8 deletions
diff --git a/src/plugins/bar.ts b/src/plugins/bar.ts
index d503e8a..76d1a8f 100644
--- a/src/plugins/bar.ts
+++ b/src/plugins/bar.ts
@@ -1,3 +1,10 @@
-export default {
- name: "bar"
-}; \ No newline at end of file
+import definePlugin from '../utils/types';
+
+export default definePlugin({
+ name: "bar",
+ description: "Just to test",
+ author: ["Vendicated"],
+ start() {
+ console.log("bar");
+ }
+}); \ No newline at end of file
diff --git a/src/plugins/foo.ts b/src/plugins/foo.ts
index 64c9323..f365b31 100644
--- a/src/plugins/foo.ts
+++ b/src/plugins/foo.ts
@@ -1,3 +1,10 @@
-export default {
- name: "foo"
-}; \ No newline at end of file
+import definePlugin from "../utils/types";
+
+export default definePlugin({
+ name: "foo",
+ description: "Just to test",
+ author: ["Vendicated"],
+ start() {
+ console.log("foo");
+ }
+}); \ No newline at end of file
diff --git a/src/plugins/index.ts b/src/plugins/index.ts
index 4e55edb..d5b419b 100644
--- a/src/plugins/index.ts
+++ b/src/plugins/index.ts
@@ -1,3 +1,27 @@
-import plugins from "plugins";
+import Plugins from "plugins";
+import Logger from "../utils/logger";
+import { Patch } from "../utils/types";
-console.log(plugins); \ No newline at end of file
+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);
+ }
+ }
+} \ No newline at end of file