Make command loader use the default class
This commit is contained in:
parent
1b1933a9ce
commit
00a057792b
2 changed files with 6 additions and 6 deletions
|
@ -20,7 +20,7 @@ export class Events {
|
||||||
|
|
||||||
// Emit when a message is sent
|
// Emit when a message is sent
|
||||||
// Used to check for commands
|
// Used to check for commands
|
||||||
public onMessage(message: Message): IEventResponse {
|
public async onMessage(message: Message): Promise<IEventResponse> {
|
||||||
if (!message.guild) return {
|
if (!message.guild) return {
|
||||||
valid: false,
|
valid: false,
|
||||||
message: "Message was not sent in a guild, ignoring.",
|
message: "Message was not sent in a guild, ignoring.",
|
||||||
|
@ -42,7 +42,7 @@ export class Events {
|
||||||
message: "Command name was not found",
|
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) {
|
if (!res.valid) {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -16,7 +16,7 @@ export interface IUtilResponse extends IBaseResponse {
|
||||||
|
|
||||||
// Util Class
|
// Util Class
|
||||||
export class Util {
|
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 {
|
if (!message.member) return {
|
||||||
valid: false,
|
valid: false,
|
||||||
message: "Member is not part of message",
|
message: "Member is not part of message",
|
||||||
|
@ -37,9 +37,9 @@ export class Util {
|
||||||
|
|
||||||
if (existsSync(`${process.cwd()}/${folder}/`)) {
|
if (existsSync(`${process.cwd()}/${folder}/`)) {
|
||||||
if (existsSync(`${process.cwd()}/${folder}/${name}.ts`)) {
|
if (existsSync(`${process.cwd()}/${folder}/${name}.ts`)) {
|
||||||
const commandFile = require(`${process.cwd()}/${folder}/${name}.ts`);
|
const commandFile = require(`${process.cwd()}/${folder}/${name}.ts`).default;
|
||||||
const command = new commandFile[name]() as Command;
|
const command = new commandFile() as Command;
|
||||||
|
|
||||||
const requiredRoles = command._roles;
|
const requiredRoles = command._roles;
|
||||||
|
|
||||||
if (!command._category) command._category = "none";
|
if (!command._category) command._category = "none";
|
||||||
|
|
Reference in a new issue