Working on getting event handler to pass each object obj, next. next() invoking the next object in the array of callbacks

This commit is contained in:
plane000
2018-10-28 21:57:56 +00:00
parent 1e5f0b7bc4
commit 7e055552fb
2 changed files with 22 additions and 3 deletions

View File

@@ -1,15 +1,30 @@
import {Logger} from './logger';
import {Config} from './config';
export class Events {
export class Events { // extends rate limits
async init(client) {
this.client = client;
this.client.login(Config.Token);
}
async handleEvents() {
this.client.on('ready', () => {this.handleReady()});
this.client.on('message', async (message) => {this.handleMessage(message)});
this.client.on('ready', async () => {
this.handle(undefined,
[this.handleReady, this.anotherCallback]
);
});
this.client.on('message', async (message) => {
this.handle(message,
[this.handleMessage]
);
});
}
async handle(obj = [null], callbacks = [undefined]) {
// const next = undefined;
// if (callbacks[i+1]) const next = callbacks[i+1];
// callbacks[i](obj, next);
}
async handleReady() {
@@ -19,6 +34,10 @@ export class Events {
Logger.ready();
}
async anotherCallback() {
Logger.debug(1);
}
async handleMessage(...args) {
Logger.info(args[0]);
args[0].channel.send('lol u homo')

0
src/ratelimits.js Normal file
View File