mirror of
https://github.com/jaronpate/unicord.git
synced 2026-10-19 05:57:38 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d8b85e60ec |
@@ -205,15 +205,15 @@ export class Gateway {
|
|||||||
// Generate context
|
// Generate context
|
||||||
const context = new Context(this.client, this.api, { message });
|
const context = new Context(this.client, this.api, { message });
|
||||||
// Dispatch event for the command
|
// Dispatch event for the command
|
||||||
// this.bus.emit(`${HandlerType.ChatCommands}:${command}`, context, args);
|
this.bus.emit(`${HandlerType.ChatCommands}:${command}`, context, args);
|
||||||
// // Check if command exists
|
// // Check if command exists
|
||||||
if (this.processor[HandlerType.ChatCommands].has(command)) {
|
// if (this.processor[HandlerType.ChatCommands].has(command)) {
|
||||||
// Execute the handler
|
// // Execute the handler
|
||||||
this.processor[HandlerType.ChatCommands].execute(command, context, args);
|
// this.processor[HandlerType.ChatCommands].execute(command, context, args);
|
||||||
} else {
|
// } else {
|
||||||
// TODO: Custom unknown command handler
|
// // TODO: Custom unknown command handler
|
||||||
// context.reply(`Unknown command: ${command}`);
|
// // context.reply(`Unknown command: ${command}`);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export class Processor {
|
|||||||
const handlers = this.handlers[type].get(e) || [];
|
const handlers = this.handlers[type].get(e) || [];
|
||||||
handlers.push(handler);
|
handlers.push(handler);
|
||||||
this.handlers[type].set(e, handlers);
|
this.handlers[type].set(e, handlers);
|
||||||
|
this.bus.on(`${type}:${e}`, async (context: Context | null, payload: any) => { this.execute(type, e, context, payload) });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -50,9 +51,10 @@ export class Processor {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public async execute(type: HandlerType.Events, event: string, context: Context | null, payload: EventPayload): Promise<void>
|
// TODO: Fix overloads
|
||||||
public async execute(type: HandlerType.Interactions, event: string, context: Context | null, payload: InteractionData): Promise<void>
|
// public async execute(type: HandlerType.Events, event: string, context: Context | null, payload: EventPayload): Promise<void>
|
||||||
public async execute(type: Omit<HandlerType, HandlerType.Events | HandlerType.Interactions>, event: string, context: Context, args: any[]): Promise<void>
|
// public async execute(type: HandlerType.Interactions, event: string, context: Context | null, payload: InteractionData): Promise<void>
|
||||||
|
// public async execute(type: Omit<HandlerType, HandlerType.Events | HandlerType.Interactions>, event: string, context: Context, args: any[]): Promise<void>
|
||||||
public async execute(type: HandlerType, event: string, context: Context | null, argsOrPayload: any[] | EventPayload) {
|
public async execute(type: HandlerType, event: string, context: Context | null, argsOrPayload: any[] | EventPayload) {
|
||||||
const handlers = this.handlers[type].get(event);
|
const handlers = this.handlers[type].get(event);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user