fix: client.destroy()
This commit is contained in:
		| @@ -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<void> | 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; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|   | ||||
| @@ -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 | ||||
|     } | ||||
|   } | ||||
|   | ||||
| @@ -280,7 +280,7 @@ new DiscordAuthWebsocket({ | ||||
|   _heartbeatAck() { | ||||
|     setTimeout(() => { | ||||
|       this._heartbeat(); | ||||
|     }, this.heartbeatInterval); | ||||
|     }, this.heartbeatInterval).unref(); | ||||
|   } | ||||
|   _ready(data) { | ||||
|     this._logger('debug', 'Attempting server handshake...'); | ||||
|   | ||||
| @@ -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'); | ||||
|   } | ||||
|   | ||||
| @@ -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, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user