Make command loader use the default class

This commit is contained in:
Ethan Lane 2021-09-26 14:12:21 +01:00
parent 1b1933a9ce
commit 00a057792b
Signed by: Vylpes
GPG key ID: EED233CC06D12504
2 changed files with 6 additions and 6 deletions

View file

@ -20,7 +20,7 @@ export class Events {
// Emit when a message is sent
// Used to check for commands
public onMessage(message: Message): IEventResponse {
public async onMessage(message: Message): Promise<IEventResponse> {
if (!message.guild) return {
valid: false,
message: "Message was not sent in a guild, ignoring.",
@ -42,7 +42,7 @@ export class Events {
message: "Command name was not found",
};
const res = this._util.loadCommand(name, args, message);
const res = await this._util.loadCommand(name, args, message);
if (!res.valid) {
return {

View file

@ -16,7 +16,7 @@ export interface IUtilResponse extends IBaseResponse {
// Util Class
export class Util {
public loadCommand(name: string, args: string[], message: Message): IUtilResponse {
public async loadCommand(name: string, args: string[], message: Message): Promise<IUtilResponse> {
if (!message.member) return {
valid: false,
message: "Member is not part of message",
@ -37,8 +37,8 @@ export class Util {
if (existsSync(`${process.cwd()}/${folder}/`)) {
if (existsSync(`${process.cwd()}/${folder}/${name}.ts`)) {
const commandFile = require(`${process.cwd()}/${folder}/${name}.ts`);
const command = new commandFile[name]() as Command;
const commandFile = require(`${process.cwd()}/${folder}/${name}.ts`).default;
const command = new commandFile() as Command;
const requiredRoles = command._roles;