lotus-tree-types 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -35
- package/.github/ci-publish.yml +0 -25
- package/.prettierignore +0 -3
- package/.prettierrc +0 -1
- package/.vscode/launch.json +0 -15
- package/README.md +0 -1
- package/dist/lotus/app.js +0 -84
- package/dist/lotus/index.js +0 -2
- package/dist/lotus/loadPackage.js +0 -46
- package/dist/lotus/types.js +0 -2
- package/eslint.config.mjs +0 -16
- package/nodemon.json +0 -8
- package/package-types.json +0 -27
- package/src/app.ts +0 -126
- package/src/config/lotus.example.json +0 -11
- package/src/index.ts +0 -41
- package/src/loadPackage.ts +0 -49
- package/tsconfig.json +0 -14
- /package/{dist/types/app.d.ts → app.d.ts} +0 -0
- /package/{dist/types/index.d.ts → index.d.ts} +0 -0
- /package/{dist/types/loadPackage.d.ts → loadPackage.d.ts} +0 -0
- /package/{dist/types/types.d.ts → types.d.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lotus-tree-types",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"private": false,
|
|
5
|
-
"description": "",
|
|
3
|
+
"version": "2.0.2",
|
|
6
4
|
"homepage": "https://github.com/jorgev259/Lotus-Tree#readme",
|
|
7
5
|
"bugs": {
|
|
8
6
|
"url": "https://github.com/jorgev259/Lotus-Tree/issues"
|
|
@@ -11,43 +9,12 @@
|
|
|
11
9
|
"type": "git",
|
|
12
10
|
"url": "https://github.com/jorgev259/Lotus-Tree.git"
|
|
13
11
|
},
|
|
14
|
-
"license": "ISC",
|
|
15
|
-
"author": "",
|
|
16
12
|
"type": "module",
|
|
17
|
-
"main": "
|
|
18
|
-
"scripts": {
|
|
19
|
-
"build": "tsc",
|
|
20
|
-
"dev": "tsx --watch src/index.ts"
|
|
21
|
-
},
|
|
13
|
+
"main": "index.d.ts",
|
|
22
14
|
"dependencies": {
|
|
23
15
|
"discord.js": "^14.14.1",
|
|
24
|
-
"fs-extra": "^11.2.0",
|
|
25
16
|
"sequelize": "^6.35.2"
|
|
26
17
|
},
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"@eslint/config-helpers": "^0.5.0",
|
|
29
|
-
"@eslint/eslintrc": "^3.3.3",
|
|
30
|
-
"@eslint/js": "^9.39.2",
|
|
31
|
-
"@tsconfig/node-lts": "^24.0.0",
|
|
32
|
-
"@tsconfig/node-ts": "^23.6.2",
|
|
33
|
-
"@types/fs-extra": "^11.0.4",
|
|
34
|
-
"@types/node": "^25.0.3",
|
|
35
|
-
"eslint": "^8.0.1",
|
|
36
|
-
"eslint-config-prettier": "^10.1.8",
|
|
37
|
-
"eslint-config-standard": "^17.1.0",
|
|
38
|
-
"eslint-plugin-import": "^2.25.2",
|
|
39
|
-
"eslint-plugin-n": "^15.0.0 || ^16.0.0 ",
|
|
40
|
-
"eslint-plugin-promise": "^6.0.0",
|
|
41
|
-
"globals": "^17.0.0",
|
|
42
|
-
"prettier": "^3.7.4",
|
|
43
|
-
"prettier-config-standard": "^7.0.0",
|
|
44
|
-
"tsx": "^4.21.0",
|
|
45
|
-
"typescript": "^5.9.3",
|
|
46
|
-
"typescript-eslint": "^8.51.0"
|
|
47
|
-
},
|
|
48
|
-
"peerDependencies": {
|
|
49
|
-
"sqlite3": "^5.1.7"
|
|
50
|
-
},
|
|
51
18
|
"engines": {
|
|
52
19
|
"node": "24.x"
|
|
53
20
|
}
|
package/.github/ci-publish.yml
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
name: Publish pipeline
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
workflow_dispatch:
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
build-types:
|
|
9
|
-
runs-on: ubuntu-latest
|
|
10
|
-
steps:
|
|
11
|
-
- uses: actions/checkout@v6
|
|
12
|
-
- uses: actions/setup-node@v6
|
|
13
|
-
with:
|
|
14
|
-
node-version: latest
|
|
15
|
-
caceh: yarn
|
|
16
|
-
- name: 'Create .npmrc'
|
|
17
|
-
run: |
|
|
18
|
-
echo "registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc
|
|
19
|
-
- name: Prepare build-types
|
|
20
|
-
run: |
|
|
21
|
-
yarn -y
|
|
22
|
-
yarn build
|
|
23
|
-
cp package-types.json dist/types/
|
|
24
|
-
cd dist/types/
|
|
25
|
-
npm publish
|
package/.prettierignore
DELETED
package/.prettierrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"prettier-config-standard"
|
package/.vscode/launch.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": "0.2.0",
|
|
3
|
-
"configurations": [
|
|
4
|
-
{
|
|
5
|
-
"type": "node",
|
|
6
|
-
"request": "launch",
|
|
7
|
-
"name": "Launch dev",
|
|
8
|
-
"runtimeExecutable": "yarn",
|
|
9
|
-
"runtimeArgs": ["dev"],
|
|
10
|
-
"cwd": "${workspaceFolder}/src",
|
|
11
|
-
"console": "integratedTerminal",
|
|
12
|
-
"internalConsoleOptions": "neverOpen"
|
|
13
|
-
}
|
|
14
|
-
]
|
|
15
|
-
}
|
package/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# lotus-core
|
package/dist/lotus/app.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { Sequelize } from 'sequelize';
|
|
2
|
-
import { Client, Events, GatewayIntentBits, Partials } from 'discord.js';
|
|
3
|
-
import { loadModule } from "./loadPackage.js";
|
|
4
|
-
import lotusConfig from './config/lotus.json' with { type: 'json' };
|
|
5
|
-
const { sequelize: sequelizeConfig, discord: discordConfig, packages: packageList } = lotusConfig;
|
|
6
|
-
const sequelize = new Sequelize(sequelizeConfig);
|
|
7
|
-
const events = new Map();
|
|
8
|
-
const commands = new Map();
|
|
9
|
-
const modules = new Map();
|
|
10
|
-
const intents = new Set();
|
|
11
|
-
const partials = new Set();
|
|
12
|
-
const defaultConfig = { guild: {}, global: {} };
|
|
13
|
-
const config = {};
|
|
14
|
-
const localConfig = {};
|
|
15
|
-
const packages = (await Promise.all(packageList.map((p) => loadModule(p, sequelize)))).filter((p) => p !== null);
|
|
16
|
-
packages.forEach((pkg) => {
|
|
17
|
-
const { name, intents: packageIntents, partials: packagePartials, events: packageEvents, commands: packageCommands, config, localConfig: pkgLocalConfig } = pkg;
|
|
18
|
-
const commandNames = [];
|
|
19
|
-
localConfig[name] = {};
|
|
20
|
-
packageIntents?.forEach((intent) => intents.add(intent));
|
|
21
|
-
packagePartials?.forEach((partial) => partials.add(partial));
|
|
22
|
-
if (packageEvents) {
|
|
23
|
-
for (const [name, fn] of Object.entries(packageEvents)) {
|
|
24
|
-
if (!events.has(name))
|
|
25
|
-
events.set(name, [fn]);
|
|
26
|
-
else
|
|
27
|
-
events.set(name, [...(events.get(name) || []), fn]);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
if (packageCommands) {
|
|
31
|
-
for (const [name, command] of Object.entries(packageCommands)) {
|
|
32
|
-
command.name = name;
|
|
33
|
-
command.moduleName = pkg.name;
|
|
34
|
-
command.enabled = {};
|
|
35
|
-
commands.set(name, command);
|
|
36
|
-
commandNames.push(name);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
if (config?.global) {
|
|
40
|
-
for (const [name, value] of Object.entries(config.global || {})) {
|
|
41
|
-
defaultConfig.global[name] = value;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (config?.guild) {
|
|
45
|
-
for (const [name, value] of Object.entries(config.guild || {})) {
|
|
46
|
-
defaultConfig.guild[name] = value;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
if (pkgLocalConfig) {
|
|
50
|
-
for (const [configName, value] of Object.entries(pkgLocalConfig)) {
|
|
51
|
-
localConfig[name][configName] = value;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
const module = { name, commandNames, enabled: {} };
|
|
55
|
-
modules.set(name, module);
|
|
56
|
-
});
|
|
57
|
-
const client = new Client({
|
|
58
|
-
intents: Array.from(intents),
|
|
59
|
-
partials: Array.from(partials)
|
|
60
|
-
});
|
|
61
|
-
const globals = {
|
|
62
|
-
sequelize,
|
|
63
|
-
client,
|
|
64
|
-
commands,
|
|
65
|
-
defaultConfig,
|
|
66
|
-
config,
|
|
67
|
-
localConfig,
|
|
68
|
-
modules,
|
|
69
|
-
lotusConfig
|
|
70
|
-
};
|
|
71
|
-
for (const [eventName, eventList] of events.entries()) {
|
|
72
|
-
client.on(eventName, (...args) => eventList.forEach((item) => {
|
|
73
|
-
try {
|
|
74
|
-
item(globals, ...args);
|
|
75
|
-
}
|
|
76
|
-
catch (err) {
|
|
77
|
-
console.log(err);
|
|
78
|
-
}
|
|
79
|
-
}));
|
|
80
|
-
}
|
|
81
|
-
client.once(Events.ClientReady, () => {
|
|
82
|
-
console.log(`Discord bot started! Logged in as ${client.user?.tag}`);
|
|
83
|
-
});
|
|
84
|
-
client.login(discordConfig.token);
|
package/dist/lotus/index.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
-
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
-
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
-
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
-
});
|
|
6
|
-
}
|
|
7
|
-
return path;
|
|
8
|
-
};
|
|
9
|
-
import fs from 'fs-extra';
|
|
10
|
-
import path from 'path';
|
|
11
|
-
import { Sequelize } from 'sequelize';
|
|
12
|
-
export async function loadModule(packagePath, sequelize) {
|
|
13
|
-
const { default: packageObj } = (await import(__rewriteRelativeImportExtension(packagePath)));
|
|
14
|
-
const { name } = packageObj;
|
|
15
|
-
try {
|
|
16
|
-
const { preload, localConfig, commands = {}, events = {} } = packageObj;
|
|
17
|
-
if (localConfig) {
|
|
18
|
-
const configPath = path.join('./config/', `${name}.json`);
|
|
19
|
-
const configExists = await fs.pathExists(configPath);
|
|
20
|
-
if (!configExists) {
|
|
21
|
-
await fs.writeJson(configPath, localConfig);
|
|
22
|
-
throw new Error(`${configPath} has been created. Edit the file then restart the bot`);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
packageObj.localConfig = await fs.readJSON(configPath);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
if (preload)
|
|
29
|
-
await preload(sequelize);
|
|
30
|
-
const commandSize = Object.values(commands).length;
|
|
31
|
-
const eventSize = Object.values(events).length;
|
|
32
|
-
const loadedText = commandSize > 0 && eventSize > 0
|
|
33
|
-
? ` with ${commandSize} commands and ${eventSize} events`
|
|
34
|
-
: commandSize > 0
|
|
35
|
-
? ` with ${commandSize} commands`
|
|
36
|
-
: eventSize > 0
|
|
37
|
-
? ` with ${eventSize} events`
|
|
38
|
-
: '';
|
|
39
|
-
console.log(`Loaded ${name}${loadedText}`);
|
|
40
|
-
return packageObj;
|
|
41
|
-
}
|
|
42
|
-
catch (err) {
|
|
43
|
-
console.error(err, `Failed to load ${name}`);
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
}
|
package/dist/lotus/types.js
DELETED
package/eslint.config.mjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath } from 'url'
|
|
2
|
-
import { dirname } from 'path'
|
|
3
|
-
import { defineConfig } from '@eslint/config-helpers'
|
|
4
|
-
import { FlatCompat } from '@eslint/eslintrc'
|
|
5
|
-
|
|
6
|
-
import config from 'eslint-config-standard'
|
|
7
|
-
import eslintConfigPrettier from 'eslint-config-prettier/flat'
|
|
8
|
-
|
|
9
|
-
const __filename = fileURLToPath(import.meta.url)
|
|
10
|
-
const __dirname = dirname(__filename)
|
|
11
|
-
|
|
12
|
-
const compat = new FlatCompat({
|
|
13
|
-
baseDirectory: __dirname
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
export default defineConfig([...compat.config(config), eslintConfigPrettier])
|
package/nodemon.json
DELETED
package/package-types.json
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@rikumax/lotus-tree-types",
|
|
3
|
-
"version": "2.0.2",
|
|
4
|
-
"private": false,
|
|
5
|
-
"description": "",
|
|
6
|
-
"homepage": "https://github.com/jorgev259/Lotus-Tree#readme",
|
|
7
|
-
"bugs": {
|
|
8
|
-
"url": "https://github.com/jorgev259/Lotus-Tree/issues"
|
|
9
|
-
},
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "git+https://github.com/jorgev259/Lotus-Tree.git"
|
|
13
|
-
},
|
|
14
|
-
"type": "module",
|
|
15
|
-
"main": "index.d.ts",
|
|
16
|
-
"scripts": {
|
|
17
|
-
"build": "tsc",
|
|
18
|
-
"dev": "tsx --watch src/index.ts"
|
|
19
|
-
},
|
|
20
|
-
"dependencies": {
|
|
21
|
-
"discord.js": "^14.14.1",
|
|
22
|
-
"sequelize": "^6.35.2"
|
|
23
|
-
},
|
|
24
|
-
"engines": {
|
|
25
|
-
"node": "24.x"
|
|
26
|
-
}
|
|
27
|
-
}
|
package/src/app.ts
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { Sequelize } from 'sequelize'
|
|
2
|
-
import { Client, Events, GatewayIntentBits, Partials } from 'discord.js'
|
|
3
|
-
|
|
4
|
-
import { loadModule } from './loadPackage.ts'
|
|
5
|
-
import type {
|
|
6
|
-
LocalConfig,
|
|
7
|
-
Package,
|
|
8
|
-
Config,
|
|
9
|
-
LotusConfig,
|
|
10
|
-
EventFunction,
|
|
11
|
-
Globals
|
|
12
|
-
} from './index.ts'
|
|
13
|
-
|
|
14
|
-
import lotusConfig from './config/lotus.json' with { type: 'json' }
|
|
15
|
-
|
|
16
|
-
const {
|
|
17
|
-
sequelize: sequelizeConfig,
|
|
18
|
-
discord: discordConfig,
|
|
19
|
-
packages: packageList
|
|
20
|
-
} = lotusConfig as LotusConfig
|
|
21
|
-
const sequelize = new Sequelize(sequelizeConfig)
|
|
22
|
-
|
|
23
|
-
const events = new Map<string, EventFunction[]>()
|
|
24
|
-
const commands = new Map()
|
|
25
|
-
const modules = new Map()
|
|
26
|
-
|
|
27
|
-
const intents = new Set<GatewayIntentBits>()
|
|
28
|
-
const partials = new Set<Partials>()
|
|
29
|
-
|
|
30
|
-
const defaultConfig: Config = { guild: {}, global: {} }
|
|
31
|
-
const config = {}
|
|
32
|
-
const localConfig = {} as LocalConfig
|
|
33
|
-
|
|
34
|
-
const packages = (
|
|
35
|
-
await Promise.all(packageList.map((p) => loadModule(p, sequelize)))
|
|
36
|
-
).filter((p: Package | null) => p !== null) as Package[]
|
|
37
|
-
|
|
38
|
-
packages.forEach((pkg) => {
|
|
39
|
-
const {
|
|
40
|
-
name,
|
|
41
|
-
intents: packageIntents,
|
|
42
|
-
partials: packagePartials,
|
|
43
|
-
events: packageEvents,
|
|
44
|
-
commands: packageCommands,
|
|
45
|
-
config,
|
|
46
|
-
localConfig: pkgLocalConfig
|
|
47
|
-
} = pkg
|
|
48
|
-
|
|
49
|
-
const commandNames = []
|
|
50
|
-
localConfig[name] = {}
|
|
51
|
-
|
|
52
|
-
packageIntents?.forEach((intent) => intents.add(intent))
|
|
53
|
-
packagePartials?.forEach((partial) => partials.add(partial))
|
|
54
|
-
|
|
55
|
-
if (packageEvents) {
|
|
56
|
-
for (const [name, fn] of Object.entries(packageEvents)) {
|
|
57
|
-
if (!events.has(name)) events.set(name, [fn])
|
|
58
|
-
else events.set(name, [...(events.get(name) || []), fn])
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (packageCommands) {
|
|
63
|
-
for (const [name, command] of Object.entries(packageCommands)) {
|
|
64
|
-
command.name = name
|
|
65
|
-
command.moduleName = pkg.name
|
|
66
|
-
command.enabled = {}
|
|
67
|
-
commands.set(name, command)
|
|
68
|
-
commandNames.push(name)
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (config?.global) {
|
|
73
|
-
for (const [name, value] of Object.entries(config.global || {})) {
|
|
74
|
-
defaultConfig.global[name] = value
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (config?.guild) {
|
|
79
|
-
for (const [name, value] of Object.entries(config.guild || {})) {
|
|
80
|
-
defaultConfig.guild[name] = value
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (pkgLocalConfig) {
|
|
85
|
-
for (const [configName, value] of Object.entries(pkgLocalConfig)) {
|
|
86
|
-
localConfig[name][configName] = value
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const module = { name, commandNames, enabled: {} }
|
|
91
|
-
modules.set(name, module)
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
const client = new Client({
|
|
95
|
-
intents: Array.from(intents),
|
|
96
|
-
partials: Array.from(partials)
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
const globals = {
|
|
100
|
-
sequelize,
|
|
101
|
-
client,
|
|
102
|
-
commands,
|
|
103
|
-
defaultConfig,
|
|
104
|
-
config,
|
|
105
|
-
localConfig,
|
|
106
|
-
modules,
|
|
107
|
-
lotusConfig
|
|
108
|
-
} as Globals
|
|
109
|
-
|
|
110
|
-
for (const [eventName, eventList] of events.entries()) {
|
|
111
|
-
client.on(eventName, (...args) =>
|
|
112
|
-
eventList.forEach((item) => {
|
|
113
|
-
try {
|
|
114
|
-
item(globals, ...args)
|
|
115
|
-
} catch (err) {
|
|
116
|
-
console.log(err)
|
|
117
|
-
}
|
|
118
|
-
})
|
|
119
|
-
)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
client.once(Events.ClientReady, () => {
|
|
123
|
-
console.log(`Discord bot started! Logged in as ${client.user?.tag}`)
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
client.login(discordConfig.token)
|
package/src/index.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Client, Events, GatewayIntentBits, Partials } from 'discord.js'
|
|
2
|
-
import { type Options, Sequelize } from 'sequelize'
|
|
3
|
-
|
|
4
|
-
export interface Config {
|
|
5
|
-
guild: Record<string, any>
|
|
6
|
-
global: Record<string, any>
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export type LocalConfig = Record<string, Record<string, any>>
|
|
10
|
-
|
|
11
|
-
export type EventFunction = (globals: Globals, ...args: any[]) => void
|
|
12
|
-
|
|
13
|
-
export interface Package {
|
|
14
|
-
name: string
|
|
15
|
-
intents?: GatewayIntentBits[]
|
|
16
|
-
partials?: Partials[]
|
|
17
|
-
events?: Record<Events, EventFunction>
|
|
18
|
-
commands?: Record<string, any>
|
|
19
|
-
config?: Config
|
|
20
|
-
localConfig?: LocalConfig
|
|
21
|
-
preload?: (sequelize: Sequelize) => Promise<void>
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface LotusConfig {
|
|
25
|
-
sequelize: Options
|
|
26
|
-
discord: {
|
|
27
|
-
token: string
|
|
28
|
-
}
|
|
29
|
-
packages: string[]
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface Globals {
|
|
33
|
-
sequelize: Sequelize
|
|
34
|
-
client: Client<boolean>
|
|
35
|
-
commands: Map<any, any>
|
|
36
|
-
defaultConfig: Config
|
|
37
|
-
config: {}
|
|
38
|
-
localConfig: LocalConfig
|
|
39
|
-
modules: Map<any, any>
|
|
40
|
-
lotusConfig: LotusConfig
|
|
41
|
-
}
|
package/src/loadPackage.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import fs from 'fs-extra'
|
|
2
|
-
import path from 'path'
|
|
3
|
-
import { Sequelize } from 'sequelize'
|
|
4
|
-
import type { Package } from './index.ts'
|
|
5
|
-
|
|
6
|
-
export async function loadModule(packagePath: string, sequelize: Sequelize) {
|
|
7
|
-
const { default: packageObj } = (await import(packagePath)) as {
|
|
8
|
-
default: Package
|
|
9
|
-
}
|
|
10
|
-
const { name } = packageObj
|
|
11
|
-
|
|
12
|
-
try {
|
|
13
|
-
const { preload, localConfig, commands = {}, events = {} } = packageObj
|
|
14
|
-
|
|
15
|
-
if (localConfig) {
|
|
16
|
-
const configPath = path.join('./config/', `${name}.json`)
|
|
17
|
-
const configExists = await fs.pathExists(configPath)
|
|
18
|
-
|
|
19
|
-
if (!configExists) {
|
|
20
|
-
await fs.writeJson(configPath, localConfig)
|
|
21
|
-
throw new Error(
|
|
22
|
-
`${configPath} has been created. Edit the file then restart the bot`
|
|
23
|
-
)
|
|
24
|
-
} else {
|
|
25
|
-
packageObj.localConfig = await fs.readJSON(configPath)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
if (preload) await preload(sequelize)
|
|
29
|
-
|
|
30
|
-
const commandSize = Object.values(commands).length
|
|
31
|
-
const eventSize = Object.values(events).length
|
|
32
|
-
|
|
33
|
-
const loadedText =
|
|
34
|
-
commandSize > 0 && eventSize > 0
|
|
35
|
-
? ` with ${commandSize} commands and ${eventSize} events`
|
|
36
|
-
: commandSize > 0
|
|
37
|
-
? ` with ${commandSize} commands`
|
|
38
|
-
: eventSize > 0
|
|
39
|
-
? ` with ${eventSize} events`
|
|
40
|
-
: ''
|
|
41
|
-
|
|
42
|
-
console.log(`Loaded ${name}${loadedText}`)
|
|
43
|
-
return packageObj
|
|
44
|
-
} catch (err) {
|
|
45
|
-
console.error(err, `Failed to load ${name}`)
|
|
46
|
-
|
|
47
|
-
return null
|
|
48
|
-
}
|
|
49
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": [
|
|
3
|
-
"@tsconfig/node-lts/tsconfig.json",
|
|
4
|
-
"@tsconfig/node-ts/tsconfig.json"
|
|
5
|
-
],
|
|
6
|
-
"compilerOptions": {
|
|
7
|
-
"baseUrl": "./",
|
|
8
|
-
"declaration": true,
|
|
9
|
-
"declarationDir": "./dist/types/",
|
|
10
|
-
"outDir": "./dist/lotus/",
|
|
11
|
-
"rootDir": "./src/",
|
|
12
|
-
"resolveJsonModule": true
|
|
13
|
-
}
|
|
14
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|