Use actions/events for plugin interoperability. Move base case and mute functionality to their own plugins.
This commit is contained in:
parent
22c515be38
commit
2e30a3b9e7
14 changed files with 674 additions and 332 deletions
24
src/data/GuildActions.ts
Normal file
24
src/data/GuildActions.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue