mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 17:43:30 +01:00
partially working autorevive
This commit is contained in:
@@ -125,6 +125,11 @@ var InternalClient = (function () {
|
||||
function InternalClient(discordClient) {
|
||||
_classCallCheck(this, InternalClient);
|
||||
|
||||
this.setup(discordClient);
|
||||
}
|
||||
|
||||
InternalClient.prototype.setup = function setup(discordClient) {
|
||||
discordClient = discordClient || this.client;
|
||||
this.client = discordClient;
|
||||
this.state = _ConnectionState2["default"].IDLE;
|
||||
this.websocket = null;
|
||||
@@ -149,7 +154,7 @@ var InternalClient = (function () {
|
||||
this.resolver = new _ResolverResolver2["default"](this);
|
||||
this.readyTime = null;
|
||||
this.messageAwaits = {};
|
||||
}
|
||||
};
|
||||
|
||||
InternalClient.prototype.cleanIntervals = function cleanIntervals() {
|
||||
for (var _iterator = this.intervals.typing.concat(this.intervals.misc).concat(this.intervals.kai), _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
||||
@@ -172,6 +177,21 @@ var InternalClient = (function () {
|
||||
}
|
||||
};
|
||||
|
||||
InternalClient.prototype.disconnected = function disconnected() {
|
||||
var forced = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0];
|
||||
|
||||
this.cleanIntervals();
|
||||
|
||||
this.leaveVoiceChannel();
|
||||
|
||||
if (this.client.options.autoRevive && !forced) {
|
||||
this.setup();
|
||||
this.login(this.email, this.password);
|
||||
}
|
||||
|
||||
this.client.emit("disconnected");
|
||||
};
|
||||
|
||||
//def leaveVoiceChannel
|
||||
|
||||
InternalClient.prototype.leaveVoiceChannel = function leaveVoiceChannel() {
|
||||
@@ -1137,11 +1157,7 @@ var InternalClient = (function () {
|
||||
this.websocket.onclose = function () {
|
||||
self.websocket = null;
|
||||
self.state = _ConnectionState2["default"].DISCONNECTED;
|
||||
client.emit("disconnected");
|
||||
self.cleanIntervals();
|
||||
if (self.voiceConnection) {
|
||||
self.leaveVoiceChannel();
|
||||
}
|
||||
self.disconnected();
|
||||
};
|
||||
|
||||
this.websocket.onerror = function (e) {
|
||||
|
||||
Reference in New Issue
Block a user