mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 01:53:30 +01:00
Added message framework
This commit is contained in:
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