mirror of
https://github.com/discordjs/discord.js.git
synced 2024-08-20 18:54:45 +12:00
turbo charged caching of servers - needs full implementation
no point making extra requests, servers are cached, and they're cached properly.
This commit is contained in:
parent
2758f33710
commit
8409f6c5d6
1 changed files with 8 additions and 12 deletions
20
index.js
20
index.js
|
@ -58,10 +58,7 @@ exports.Client.prototype.off = function( name ) {
|
|||
this.events[ name ] = function() {};
|
||||
}
|
||||
|
||||
exports.Client.prototype.cacheServer = function( id, cb, members, channelInfo ) {
|
||||
|
||||
console.log("caching!");
|
||||
|
||||
exports.Client.prototype.cacheServer = function( id, cb, members ) {
|
||||
var self = this;
|
||||
var serverInput;
|
||||
|
||||
|
@ -72,8 +69,6 @@ exports.Client.prototype.cacheServer = function( id, cb, members, channelInfo )
|
|||
return;
|
||||
}
|
||||
|
||||
console.log("test");
|
||||
|
||||
request
|
||||
.get( Endpoints.SERVERS + "/" + id )
|
||||
.set( "authorization", self.token )
|
||||
|
@ -117,8 +112,9 @@ exports.Client.prototype.cacheServer = function( id, cb, members, channelInfo )
|
|||
|
||||
function makeServer( dat ) {
|
||||
server = new Server( dat.region, dat.owner_id, dat.name, id, members || dat.members, dat.icon, dat.afk_timeout, dat.afk_channel_id );
|
||||
console.log(server.id);
|
||||
if ( !channelInfo )
|
||||
if ( dat.channels )
|
||||
cacheChannels(dat.channels);
|
||||
else
|
||||
channelsFromHTTP();
|
||||
}
|
||||
|
||||
|
@ -212,15 +208,15 @@ exports.Client.prototype.connectWebsocket = function( cb ) {
|
|||
for ( x in _servers ) {
|
||||
_server = _servers[ x ];
|
||||
|
||||
var sID = "";
|
||||
/*var sID = "";
|
||||
for ( role of _server.roles ) {
|
||||
if ( role.name === "@everyone" ) {
|
||||
sID = role.id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
client.cacheServer( sID, function( server ) {
|
||||
}*/
|
||||
client.cacheServer( _server, function( server ) {
|
||||
console.log(server.name + " has " + server.members.length() + " members");
|
||||
cached++;
|
||||
if ( cached >= toCache ) {
|
||||
client.ready = true;
|
||||
|
|
Loading…
Reference in a new issue