mirror of
https://github.com/danbulant/discord.js
synced 2026-07-07 12:11:11 +00:00
Fix potentially long websocket messages
This commit is contained in:
parent
3bc6ea455d
commit
ba0c8c45fc
2 changed files with 6 additions and 6 deletions
|
|
@ -471,8 +471,8 @@ var InternalClient = (function () {
|
||||||
|
|
||||||
InternalClient.prototype.getGuildMembers = function getGuildMembers(serverID, chunkCount) {
|
InternalClient.prototype.getGuildMembers = function getGuildMembers(serverID, chunkCount) {
|
||||||
this.forceFetchCount[serverID] = chunkCount;
|
this.forceFetchCount[serverID] = chunkCount;
|
||||||
if (this.forceFetchLength + 3 + serverID.length > 4082) {
|
if (this.forceFetchLength + 3 + serverID.length > 4000) {
|
||||||
// 4096 - '{"op":8,"d":[]}'.length + 1 for lazy comma offset
|
// 4096 max, '{"op":8,"d":{"guild_id":[],"query":"","limit":0}}'.length = 49 plus some leeway
|
||||||
this.requestGuildMembers(this.forceFetchQueue);
|
this.requestGuildMembers(this.forceFetchQueue);
|
||||||
this.forceFetchQueue = [serverID];
|
this.forceFetchQueue = [serverID];
|
||||||
this.forceFetchLength = 1 + serverID.length + 3;
|
this.forceFetchLength = 1 + serverID.length + 3;
|
||||||
|
|
@ -493,8 +493,8 @@ var InternalClient = (function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
InternalClient.prototype.syncGuild = function syncGuild(guildID) {
|
InternalClient.prototype.syncGuild = function syncGuild(guildID) {
|
||||||
if (this.guildSyncQueueLength + 3 + guildID.length > 4081) {
|
if (this.guildSyncQueueLength + 3 + guildID.length > 4050) {
|
||||||
// 4096 - "{\"op\":12,\"d\":[]}".length + 1 for lazy comma offset
|
// 4096 max, '{"op":12,"d":[]}'.length = 16 plus some leeway
|
||||||
this.sendWS({ op: 12, d: this.guildSyncQueue });
|
this.sendWS({ op: 12, d: this.guildSyncQueue });
|
||||||
this.guildSyncQueue = [guildID];
|
this.guildSyncQueue = [guildID];
|
||||||
this.guildSyncQueueLength = 1 + guildID.length + 3;
|
this.guildSyncQueueLength = 1 + guildID.length + 3;
|
||||||
|
|
|
||||||
|
|
@ -373,7 +373,7 @@ export default class InternalClient {
|
||||||
|
|
||||||
getGuildMembers(serverID, chunkCount) {
|
getGuildMembers(serverID, chunkCount) {
|
||||||
this.forceFetchCount[serverID] = chunkCount;
|
this.forceFetchCount[serverID] = chunkCount;
|
||||||
if (this.forceFetchLength + 3 + serverID.length > 4082) { // 4096 - '{"op":8,"d":[]}'.length + 1 for lazy comma offset
|
if (this.forceFetchLength + 3 + serverID.length > 4000) { // 4096 max, '{"op":8,"d":{"guild_id":[],"query":"","limit":0}}'.length = 49 plus some leeway
|
||||||
this.requestGuildMembers(this.forceFetchQueue);
|
this.requestGuildMembers(this.forceFetchQueue);
|
||||||
this.forceFetchQueue = [serverID];
|
this.forceFetchQueue = [serverID];
|
||||||
this.forceFetchLength = 1 + serverID.length + 3;
|
this.forceFetchLength = 1 + serverID.length + 3;
|
||||||
|
|
@ -394,7 +394,7 @@ export default class InternalClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
syncGuild(guildID) {
|
syncGuild(guildID) {
|
||||||
if(this.guildSyncQueueLength + 3 + guildID.length > 4081) { // 4096 - "{\"op\":12,\"d\":[]}".length + 1 for lazy comma offset
|
if(this.guildSyncQueueLength + 3 + guildID.length > 4050) { // 4096 max, '{"op":12,"d":[]}'.length = 16 plus some leeway
|
||||||
this.sendWS({op: 12, d: this.guildSyncQueue});
|
this.sendWS({op: 12, d: this.guildSyncQueue});
|
||||||
this.guildSyncQueue = [guildID];
|
this.guildSyncQueue = [guildID];
|
||||||
this.guildSyncQueueLength = 1 + guildID.length + 3;
|
this.guildSyncQueueLength = 1 + guildID.length + 3;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue