Fix command and event file paths

This commit is contained in:
Marcin Czop 2024-11-19 17:55:52 +01:00
parent 0e2b7c0087
commit fa77a856ca
No known key found for this signature in database
GPG key ID: 44BCC84471234D0D
3 changed files with 9 additions and 6 deletions

View file

@ -4,7 +4,7 @@
"description": "",
"main": "index.js",
"scripts": {
"dev": "nodemon --ignore 'data/*.json' -r dotenv/config src/index.ts",
"dev": "nodemon -r dotenv/config src/index.ts",
"build": "tsc",
"start": "node build/index.js"
},

View file

@ -1,5 +1,6 @@
import { Client, Collection, GatewayIntentBits, User, Options } from "discord.js";
import { glob } from "glob";
import path from "path";
import db from "./utils/db";
import logger from "./utils/logger";
@ -31,16 +32,18 @@ class Bot extends Client {
this.login(process.env.TOKEN);
this.log.debug("Loading commands and events...");
const commandFiles: string[] = await glob(`${__dirname}/commands/**/*{.ts,.js}`);
const commandFiles: string[] = await glob(`${__dirname}/commands/**/*.ts`);
commandFiles.map(async (fileName: string) => {
const file: Command = await import(`../${fileName}`);
const filePath = path.resolve(fileName);
const file: Command = await import(filePath);
this.commands.set(file.name, file);
if (file.aliases) file.aliases.map((alias) => this.commands.set(alias, file));
});
const eventFiles: string[] = await glob(`${__dirname}/events/**/*{.ts,.js}`);
const eventFiles: string[] = await glob(`${__dirname}/events/**/*.ts`);
eventFiles.map(async (fileName: string) => {
const file: Event = await import(`../${fileName}`);
const filePath = path.resolve(fileName);
const file: Event = await import(filePath);
this.events.set(file.name, file);
this.on(file.event, file.run.bind(this, this));
});

View file

@ -1,6 +1,6 @@
import { EmbedBuilder } from "discord.js";
import { RunFunction } from "../interfaces/commands";
import { RunFunction } from "../../interfaces/commands";
export const run: RunFunction = async (client, message) => {
const embed = new EmbedBuilder()