armcord/utils/plugin.js

25 lines
721 B
JavaScript
Raw Normal View History

2021-05-16 14:29:37 +00:00
const fs = require("fs");
const { app, session } = require("electron");
const electron = require("electron");
const userDataPath = (electron.app || electron.remote.app).getPath("userData");
const pluginFolder = userDataPath + "/plugins/";
2021-05-16 14:29:37 +00:00
app.whenReady().then(() => {
fs.readdirSync(pluginFolder).forEach((file) => {
try {
const manifest = fs.readFileSync(
`${userDataPath}/plugins/${file}/manifest.json`,
2021-05-16 14:29:37 +00:00
"utf8"
);
var pluginFile = JSON.parse(manifest);
session.defaultSession.loadExtension(`${userDataPath}/plugins/${file}`);
2021-05-16 14:29:37 +00:00
console.log(
`%cLoaded ${pluginFile.name} made by ${pluginFile.author}`,
"color:red"
);
} catch (err) {
console.error(err);
}
});
});