Skip to content

Commit

Permalink
Merge pull request #20 from EvoEsports/dev
Browse files Browse the repository at this point in the history
attempt to fix plugin loader for docker
  • Loading branch information
reaby authored Jun 16, 2024
2 parents 4eaa80c + 72dfbc2 commit 6c47e37
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,4 @@ userdata/*.json
userdata/plugins/*
userdata/drizzle/*
!userdata/plugins/.gitkeep
docker-compose.yml
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ See [documentation](./documentation/index.md) for more info!
3. move `xaseco.sql` to `tools`
5. run bun from Tools folder: `bun xaseco.ts xaseco.sql`
6. start controller


# Notes
To build local docker image use: `docker build -t minicontrol:test -f docker/Dockerfile . `
15 changes: 10 additions & 5 deletions core/minicontrol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class MiniControl {
* The version of MiniControl.
*/
readonly brand: string = "$n$o$eeeMINI$o$z$s$abccontrol$z$s¤white¤";
readonly version: string = "0.3.5";
readonly version: string = "0.3.6";
/**
* The start time of MiniControl.
*/
Expand Down Expand Up @@ -348,8 +348,8 @@ class MiniControl {
async beforeInit() {
await this.chatCmd.beforeInit();
// load plugins
let plugins = fs.readdirSync("./core/plugins", { withFileTypes: true, recursive: true });
plugins = plugins.concat(fs.readdirSync("./userdata/plugins", { withFileTypes: true, recursive: true }));
let plugins = fs.readdirSync(process.cwd() + "/core/plugins", { withFileTypes: true, recursive: true });
plugins = plugins.concat(fs.readdirSync(process.cwd() + "/userdata/plugins", { withFileTypes: true, recursive: true }));
const exclude = process.env.EXCLUDED_PLUGINS?.split(",") || [];
let loadList = [];
for (const i in plugins) {
Expand All @@ -367,10 +367,15 @@ class MiniControl {
loadList.push(plugin.name.replaceAll("\\", "/"));
}
}

// load metadata
for (const name of loadList) {
const cls = await import(process.cwd() + "/" + this.findPlugin(name));
const pluginName = process.cwd() + "/" + this.findPlugin(name)
if (pluginName == null) {
const msg = `¤error¤Didn't find a plugin. resolved plugin name is null.`;
this.cli(msg);
continue;
}
const cls = await import(pluginName);
const plugin = cls.default;
if (plugin == undefined) {
const msg = `¤gray¤Plugin ¤cmd¤${name}¤error¤ failed to load. Plugin has no default export.`;
Expand Down

0 comments on commit 6c47e37

Please sign in to comment.