mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 17:13:31 +01:00
Added message framework
This commit is contained in:
@@ -14,7 +14,7 @@ exports.Channel = function(name, server, type, id, isPrivate){
|
||||
this.type = type;
|
||||
this.id = id;
|
||||
this.isPrivate = isPrivate;
|
||||
|
||||
this.messages = new List("id", "5000");
|
||||
}
|
||||
|
||||
exports.Channel.equals = function(otherChannel){
|
||||
|
||||
22
lib/list.js
22
lib/list.js
@@ -1,20 +1,32 @@
|
||||
exports.List = function( discriminator ) {
|
||||
exports.List = function( discriminator, cap ) {
|
||||
this.discriminator = discriminator;
|
||||
this.cap = cap || Number.MAX_SAFE_INTEGER;
|
||||
this.contents = [];
|
||||
}
|
||||
|
||||
exports.List.prototype.add = function( child ) {
|
||||
|
||||
var self = this;
|
||||
|
||||
if ( child.constructor === Array ) {
|
||||
|
||||
children = child;
|
||||
for ( child of children ) {
|
||||
if ( this.filter( this.discriminator, child[ this.discriminator ] ).length === 0 )
|
||||
this.contents.push( child );
|
||||
addChild(child);
|
||||
}
|
||||
|
||||
} else {
|
||||
if ( this.filter( this.discriminator, child[ this.discriminator ] ).length === 0 )
|
||||
this.contents.push( child );
|
||||
addChild(child);
|
||||
}
|
||||
|
||||
function addChild(child){
|
||||
|
||||
if(self.length() > cap){
|
||||
self.splice(0, 1);
|
||||
}
|
||||
|
||||
if ( self.filter( self.discriminator, child[ self.discriminator ] ).length === 0 )
|
||||
self.contents.push( child );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user