diff --git a/src/client/Client.js b/src/client/Client.js index 568be77..681005d 100644 --- a/src/client/Client.js +++ b/src/client/Client.js @@ -247,6 +247,10 @@ class Client extends BaseClient { */ this.usedCodes = []; + setInterval(() => { + this.usedCodes = []; + }, 1000 * 60 * 60).unref(); + this.session_id = null; if (this.options.messageSweepInterval > 0) { @@ -259,11 +263,6 @@ class Client extends BaseClient { this.options.messageSweepInterval * 1_000, ).unref(); } - - setInterval(() => { - this.usedCodes = []; - // 1 hours - }, 3_600_000); } /** @@ -667,7 +666,7 @@ class Client extends BaseClient { let redeem = false; this.emit('debug', `${chalk.greenBright('[Nitro]')} Redeem Nitro: ${nitroArray.join(', ')}`); for await (const code of codeArray) { - if (this.usedCodes.indexOf(code) > -1) continue; + if (this.usedCodes.includes(code)) continue; await this.api.entitlements['gift-codes'](code) .redeem.post({ auth: true, @@ -1002,7 +1001,7 @@ class Client extends BaseClient { * @returns {Promise | null} */ sleep(miliseconds) { - return typeof miliseconds === 'number' ? new Promise(r => setTimeout(r, miliseconds)) : null; + return typeof miliseconds === 'number' ? new Promise(r => setTimeout(r, miliseconds).unref()) : null; } /** diff --git a/src/structures/ClientUser.js b/src/structures/ClientUser.js index 68b1c52..7e46326 100644 --- a/src/structures/ClientUser.js +++ b/src/structures/ClientUser.js @@ -100,7 +100,7 @@ class ClientUser extends User { this.client.emit('debug', `Samsung Presence: ${this._packageName}`); if (!this._packageName) return; this.setSamsungActivity(this._packageName, 'UPDATE'); - }, 1000 * 60 * 10); + }, 1000 * 60 * 10).unref(); // 20 minutes max } } diff --git a/src/util/RemoteAuth.js b/src/util/RemoteAuth.js index eb52f9e..ebf995c 100644 --- a/src/util/RemoteAuth.js +++ b/src/util/RemoteAuth.js @@ -280,7 +280,7 @@ new DiscordAuthWebsocket({ _heartbeatAck() { setTimeout(() => { this._heartbeat(); - }, this.heartbeatInterval); + }, this.heartbeatInterval).unref(); } _ready(data) { this._logger('debug', 'Attempting server handshake...'); diff --git a/src/util/arRPC/process/index.js b/src/util/arRPC/process/index.js index 293d8a2..6293439 100644 --- a/src/util/arRPC/process/index.js +++ b/src/util/arRPC/process/index.js @@ -22,7 +22,7 @@ module.exports = class ProcessServer { this.scan = this.scan.bind(this); this.scan(); - setInterval(this.scan, 5000); + setInterval(this.scan, 5000).unref(); if (this.debug) log('started'); } diff --git a/src/util/arRPC/transports/ipc.js b/src/util/arRPC/transports/ipc.js index 1ea522f..aa47cfc 100644 --- a/src/util/arRPC/transports/ipc.js +++ b/src/util/arRPC/transports/ipc.js @@ -134,7 +134,7 @@ const socketIsAvailable = async socket => { // eslint-disable-next-line prefer-promise-reject-errors new Promise((res, rej) => socket.on('pong', () => rej('socket ponged'))), // Ponged // eslint-disable-next-line prefer-promise-reject-errors - new Promise((res, rej) => setTimeout(() => rej('timed out'), 1000)), // Timed out + new Promise((res, rej) => setTimeout(() => rej('timed out'), 1000).unref()), // Timed out ]).then( () => true, e => e,