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:
@@ -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
0
src/ratelimits.js
Normal file
Reference in New Issue
Block a user