mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-18 06:51:51 +00:00
25 lines
636 B
TypeScript
25 lines
636 B
TypeScript
![]() |
import { BaseRepository } from "./BaseRepository";
|
||
|
|
||
|
type ActionFn = (...args: any[]) => any | Promise<any>;
|
||
|
|
||
|
export class GuildActions extends BaseRepository {
|
||
|
private actions: Map<string, ActionFn>;
|
||
|
|
||
|
constructor(guildId) {
|
||
|
super(guildId);
|
||
|
this.actions = new Map();
|
||
|
}
|
||
|
|
||
|
public register(actionName: string, actionFn: ActionFn) {
|
||
|
this.actions.set(actionName, actionFn);
|
||
|
}
|
||
|
|
||
|
public unregister(actionName: string) {
|
||
|
this.actions.delete(actionName);
|
||
|
}
|
||
|
|
||
|
public fire(actionName: string, ...args: any[]): Promise<any> {
|
||
|
return this.actions.has(actionName) ? this.actions.get(actionName)(...args) : null;
|
||
|
}
|
||
|
}
|