diff --git a/src/index.ts b/src/index.ts index 5e100af..2f02d3a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -98,7 +98,7 @@ client.on('message', async (msg) => { return; } - findCommand.run(msg, ...args); + await findCommand.run(msg, ...args); }); client.on('ready', async () => { diff --git a/src/lib/structures/command.ts b/src/lib/structures/command.ts index 52059d7..7b062bb 100644 --- a/src/lib/structures/command.ts +++ b/src/lib/structures/command.ts @@ -22,18 +22,20 @@ import type { ICommandOptions } from '@utils/types'; export default abstract class Command { public readonly client: Client; + public readonly file: string; public readonly options: ICommandOptions; - protected constructor(client: Client, options?: ICommandOptions) { + protected constructor(client: Client, file: string, options?: ICommandOptions) { this.client = client; + this.file = file; const defaultOptions: ICommandOptions = { - name: path.basename(__filename, path.extname(__filename)), - group: path.basename(path.dirname(__filename)) === 'commands' ? '' : path.basename(path.dirname(__filename)), + name: path.basename(this.file, path.extname(this.file)), + group: path.basename(path.dirname(this.file)) === 'commands' ? '' : path.basename(path.dirname(this.file)), }; this.options = config.util.extendDeep(defaultOptions, options); } - public abstract run(message: Message, ...args: string[]): void; + public abstract run(message: Message, ...args: string[]): Promise | void; }