Add MessageCreate handler, set up Message class and add ability to Cache messages

This commit is contained in:
hydrabolt
2016-04-18 17:55:21 +01:00
parent 7f4751e7c4
commit c947e172d6
7 changed files with 93 additions and 1 deletions

View File

@@ -2,10 +2,26 @@
const Channel = require('./Channel');
const User = require('./User');
const TextChannelDataStore = require('./datastore/TextChannelDataStore');
class DMChannel extends Channel{
constructor(client, data) {
super(client, data);
this.store = new TextChannelDataStore();
}
_cacheMessage(message) {
let maxSize = this.client.options.max_message_cache;
if (maxSize === 0) {
// saves on performance
return;
}
let storeKeys = Object.keys(this.store);
if (storeKeys.length >= maxSize) {
this.store.remove(storeKeys[0]);
this.store.add('messages', message);
}
}
setup(data) {