feat: added paths in config

This commit is contained in:
Slincnik 2024-12-12 12:58:37 +03:00
parent 7109a2a0ef
commit bce6242e1e
No known key found for this signature in database
3 changed files with 13 additions and 3 deletions

View file

@ -22,5 +22,11 @@
"owner": {
"id": "123456789098765432"
},
"apiKeys": {}
"apiKeys": {},
"paths": {
"commands": "./src/commands",
"events": "./src/events",
"locales": "./src/services/languages/locales"
},
"defaultLang": "en-US"
}

View file

@ -1,3 +1,4 @@
import { resolve } from "node:path";
import logger from "../../helpers/logger.js";
import { client } from "../../index.js";
import { getFilePaths } from "../../utils/index.js";
@ -16,7 +17,8 @@ export const init = async () => {
};
const buildCommands = async () => {
const commandFilePaths = (await getFilePaths("./newCommands", true)).filter(path => path.endsWith(".js"));
const cmdPath = resolve(client.configService.get("paths.commands"));
const commandFilePaths = (await getFilePaths(cmdPath, true)).filter(path => path.endsWith(".js"));
for (const cmdFilePath of commandFilePaths) {
const { data, run } = await import(toFileURL(cmdFilePath));

View file

@ -1,3 +1,4 @@
import { resolve } from "node:path";
import logger from "../../helpers/logger.js";
import { client } from "../../index.js";
import { getFilePaths } from "../../utils/index.js";
@ -12,7 +13,8 @@ export const init = async () => {
const buildEvents = async () => {
try {
const eventFilePaths = (await getFilePaths("./newEvents", true)).filter(path => path.endsWith(".js"));
const eventPath = resolve(client.configService.get("paths.events"));
const eventFilePaths = (await getFilePaths(eventPath, true)).filter(path => path.endsWith(".js"));
for (const eventFilePath of eventFilePaths) {
const { data, run } = await import(toFileURL(eventFilePath));