mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Fix potentially long websocket messages
This commit is contained in:
@@ -471,8 +471,8 @@ var InternalClient = (function () {
|
||||
|
||||
InternalClient.prototype.getGuildMembers = function getGuildMembers(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.forceFetchQueue = [serverID];
|
||||
this.forceFetchLength = 1 + serverID.length + 3;
|
||||
@@ -493,8 +493,8 @@ var InternalClient = (function () {
|
||||
};
|
||||
|
||||
InternalClient.prototype.syncGuild = function 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.guildSyncQueue = [guildID];
|
||||
this.guildSyncQueueLength = 1 + guildID.length + 3;
|
||||
|
||||
@@ -373,7 +373,7 @@ export default class InternalClient {
|
||||
|
||||
getGuildMembers(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.forceFetchQueue = [serverID];
|
||||
this.forceFetchLength = 1 + serverID.length + 3;
|
||||
@@ -394,7 +394,7 @@ export default class InternalClient {
|
||||
}
|
||||
|
||||
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.guildSyncQueue = [guildID];
|
||||
this.guildSyncQueueLength = 1 + guildID.length + 3;
|
||||
|
||||
Reference in New Issue
Block a user