mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
Fix protocol versions
This commit is contained in:
@@ -30,7 +30,10 @@ class RESTMethods {
|
||||
getGateway() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.rest.makeRequest('get', Constants.Endpoints.gateway, true)
|
||||
.then(res => resolve(res.url))
|
||||
.then(res => {
|
||||
this.rest.client.store.gateway = `${res.url}/?encoding=json&v=${this.rest.client.options.protocol_version}`;
|
||||
resolve(this.rest.client.store.gateway);
|
||||
})
|
||||
.catch(reject);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ class WebSocketManager {
|
||||
|
||||
connect(gateway) {
|
||||
this.status = Constants.Status.CONNECTING;
|
||||
this.store.gateway = `${gateway}/?v=${this.client.options.protocol_version}`;
|
||||
this.ws = new WebSocket(gateway);
|
||||
this.ws.onopen = () => this.eventOpen();
|
||||
this.ws.onclose = () => this.eventClose();
|
||||
@@ -81,10 +80,14 @@ class WebSocketManager {
|
||||
return this.eventError(Constants.Errors.BAD_WS_MESSAGE);
|
||||
}
|
||||
|
||||
if (packet.op === 10) {
|
||||
this.client.manager.setupKeepAlive(packet.d.heartbeat_interval);
|
||||
}
|
||||
|
||||
return this.packetManager.handle(packet);
|
||||
}
|
||||
|
||||
EventError() {
|
||||
eventError() {
|
||||
this.tryReconnect();
|
||||
}
|
||||
|
||||
@@ -108,7 +111,7 @@ class WebSocketManager {
|
||||
this.ws.close();
|
||||
this.packetManager.handleQueue();
|
||||
this.client.emit(Constants.Events.RECONNECTING);
|
||||
this.connect(this.store.gateway);
|
||||
this.connect(this.client.store.gateway);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ class ReadyHandler extends AbstractHandler {
|
||||
handle(packet) {
|
||||
const data = packet.d;
|
||||
const client = this.packetManager.client;
|
||||
client.manager.setupKeepAlive(data.heartbeat_interval);
|
||||
|
||||
client.store.user = client.store.add('users', new ClientUser(client, data.user));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user