mirror of
https://github.com/danbulant/discord.js
synced 2026-05-24 12:35:53 +00:00
add auth session change handling (#1339)
* add auth session change handling * eek
This commit is contained in:
parent
4ebf4307e8
commit
5d85de0883
2 changed files with 13 additions and 0 deletions
|
|
@ -71,6 +71,16 @@ class WebSocketPacketManager {
|
|||
}
|
||||
|
||||
handle(packet) {
|
||||
if (packet.t === Constants.WSEvents.AUTH_SESSION_CHANGE) {
|
||||
if (packet.d.new_token) {
|
||||
this.client.token = packet.d.new_token;
|
||||
this.ws._sendResume();
|
||||
} else {
|
||||
this.client.destroy();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (packet.op === Constants.OPCodes.RECONNECT) {
|
||||
this.setSequence(packet.s);
|
||||
this.ws.tryReconnect();
|
||||
|
|
|
|||
|
|
@ -356,6 +356,7 @@ exports.Events = {
|
|||
* - VOICE_SERVER_UPDATE
|
||||
* - RELATIONSHIP_ADD
|
||||
* - RELATIONSHIP_REMOVE
|
||||
* - AUTH_SESSION_CHANGE
|
||||
* @typedef {string} WSEventType
|
||||
*/
|
||||
exports.WSEvents = {
|
||||
|
|
@ -393,6 +394,7 @@ exports.WSEvents = {
|
|||
VOICE_SERVER_UPDATE: 'VOICE_SERVER_UPDATE',
|
||||
RELATIONSHIP_ADD: 'RELATIONSHIP_ADD',
|
||||
RELATIONSHIP_REMOVE: 'RELATIONSHIP_REMOVE',
|
||||
AUTH_SESSION_CHANGE: 'AUTH_SESSION_CHANGE',
|
||||
};
|
||||
|
||||
exports.MessageTypes = [
|
||||
|
|
@ -441,3 +443,4 @@ exports.Colors = {
|
|||
DARK_BUT_NOT_BLACK: 0x2C2F33,
|
||||
NOT_QUITE_BLACK: 0x23272A,
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue