MessageManager still wondering how to do the command manager and module loader

This commit is contained in:
plane000
2018-11-17 16:35:44 +00:00
parent 44b5b47456
commit 0d2b9427fb
6 changed files with 31 additions and 21 deletions

10
src/commandmanager.js Normal file
View File

@@ -0,0 +1,10 @@
export class CommandLoader {
static async load() {
}
static async reload() {
}
}

View File

@@ -1,45 +1,45 @@
import {Logger} from './logger';
import {Config} from './config';
import {RateLimits} from './ratelimits'
import {MessageManager} from './messagemanager';
export class Events extends RateLimits { // extends rate limits
export class Events extends RateLimits {
constructor() {
super();
}
async init(client) {
this.client = client;
this.client.login(Config.Token);
this._client = client;
this._client.login(Config.Token);
}
get Client() {return this.client;}
async handleEvents() {
this.client.on('ready', async () => {
this._client.on('ready', async () => {
this.handle(undefined,
[this.handleReady],
this.client
this._client
);
});
this.client.on('error', async (err) => {
this._client.on('error', async (err) => {
this.handle(err,
[this.handleError],
this.client
this._client
);
});
this.client.on('message', async (message) => {
this._client.on('message', async (message) => {
this.handle(message,
[super.request, this.handleMessage],
this.client
[super.request, MessageManager.handleMessage],
this._client
);
});
}
async handle(obj = [null], callbacks = [undefined], client) {
let doNext = false;
if (callbacks.length == 0) {
@@ -70,10 +70,4 @@ export class Events extends RateLimits { // extends rate limits
Logger.error(`An error occured with the Discord API: ${err}`);
next();
}
async handleMessage(message, client, next) {
if (client.user.id == message.author.id) return;
if (message.limiting) message.channel.send(`${message.author} You are being rate limited`);
next();
}
}

View File

@@ -4,6 +4,4 @@ export class GuildManager {
constructor() {
}
}

View File

@@ -5,7 +5,7 @@ import fs from 'fs';
let LogLevel = 1;
let Dialect = 'SQLITE';
let logPath = 'logs.log';
let dateFormat = 'DD-MM-YY HH:MM:ss'
let dateFormat = 'DD-MM-YY HH:mm:ss'
export class Logger {
static init(path) {

View File

@@ -1,5 +1,13 @@
import {Logger} from './logger';
export class MessageManager {
static async init() {
}
static async handleMessage(message, client, next) {
if (client.user.id == message.author.id) return;
if (message.limiting) message.channel.send(`${message.author} You are being rate limited`);
next();
}
}