mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 11:33:30 +01:00
Fixed some caching issues and list issue
When leaving a server, it is now removed from the known list. Also, the list "removeElement" function is improved to actually work!
This commit is contained in:
9
index.js
9
index.js
@@ -238,17 +238,18 @@ exports.Client.prototype.createServer = function( _name, _region, cb ) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.Client.prototype.leaveServer = function( server, cb ){
|
exports.Client.prototype.leaveServer = function( server, cb ) {
|
||||||
|
|
||||||
var client = this;
|
var client = this;
|
||||||
|
|
||||||
request
|
request
|
||||||
.del( Endpoints.SERVERS + "/" + server.id)
|
.del( Endpoints.SERVERS + "/" + server.id )
|
||||||
.set( "authorization", client.token )
|
.set( "authorization", client.token )
|
||||||
.end( function(err, res){
|
.end( function( err, res ) {
|
||||||
if ( !res.ok ) {
|
if ( !res.ok ) {
|
||||||
cb( err );
|
cb( err );
|
||||||
} else {
|
} else {
|
||||||
|
client.serverList.removeElement( server );
|
||||||
cb( null );
|
cb( null );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
@@ -277,7 +278,7 @@ exports.Client.prototype.createInvite = function( channel, options, cb ) {
|
|||||||
if ( !res.ok ) {
|
if ( !res.ok ) {
|
||||||
cb( err );
|
cb( err );
|
||||||
} else {
|
} else {
|
||||||
cb( false, new Invite(res.body) );
|
cb( false, new Invite( res.body ) );
|
||||||
}
|
}
|
||||||
} )
|
} )
|
||||||
|
|
||||||
|
|||||||
16
lib/list.js
16
lib/list.js
@@ -28,14 +28,14 @@ exports.List.prototype.removeIndex = function( index ) {
|
|||||||
|
|
||||||
exports.List.prototype.removeElement = function( child ) {
|
exports.List.prototype.removeElement = function( child ) {
|
||||||
|
|
||||||
var index = this.contents.indexOf( child );
|
for ( _element in this.contents ) {
|
||||||
|
var element = this.contents[_element];
|
||||||
if ( index === -1 ) {
|
if ( child[ this.discriminator ] == element[ this.discriminator ] ) {
|
||||||
return false;
|
this.removeIndex( _element, 1 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.removeIndex( index );
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.List.prototype.concatSublists = function( whereList, discriminator ) {
|
exports.List.prototype.concatSublists = function( whereList, discriminator ) {
|
||||||
@@ -81,8 +81,8 @@ exports.List.prototype.deepFilter = function( keys, value, onlyOne ) {
|
|||||||
var child = this.contents[ index ];
|
var child = this.contents[ index ];
|
||||||
var buffer = child;
|
var buffer = child;
|
||||||
|
|
||||||
for(key of keys){
|
for ( key of keys ) {
|
||||||
buffer = buffer[key];
|
buffer = buffer[ key ];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( buffer == value ) {
|
if ( buffer == value ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user