mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
refactor: remove timer utilities from Client (#6113)
This commit is contained in:
@@ -84,8 +84,8 @@ class Collector extends EventEmitter {
|
||||
this.handleCollect = this.handleCollect.bind(this);
|
||||
this.handleDispose = this.handleDispose.bind(this);
|
||||
|
||||
if (options.time) this._timeout = this.client.setTimeout(() => this.stop('time'), options.time);
|
||||
if (options.idle) this._idletimeout = this.client.setTimeout(() => this.stop('idle'), options.idle);
|
||||
if (options.time) this._timeout = setTimeout(() => this.stop('time'), options.time).unref();
|
||||
if (options.idle) this._idletimeout = setTimeout(() => this.stop('idle'), options.idle).unref();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,8 +108,8 @@ class Collector extends EventEmitter {
|
||||
this.emit('collect', ...args);
|
||||
|
||||
if (this._idletimeout) {
|
||||
this.client.clearTimeout(this._idletimeout);
|
||||
this._idletimeout = this.client.setTimeout(() => this.stop('idle'), this.options.idle);
|
||||
clearTimeout(this._idletimeout);
|
||||
this._idletimeout = setTimeout(() => this.stop('idle'), this.options.idle).unref();
|
||||
}
|
||||
}
|
||||
this.checkEnd();
|
||||
@@ -179,11 +179,11 @@ class Collector extends EventEmitter {
|
||||
if (this.ended) return;
|
||||
|
||||
if (this._timeout) {
|
||||
this.client.clearTimeout(this._timeout);
|
||||
clearTimeout(this._timeout);
|
||||
this._timeout = null;
|
||||
}
|
||||
if (this._idletimeout) {
|
||||
this.client.clearTimeout(this._idletimeout);
|
||||
clearTimeout(this._idletimeout);
|
||||
this._idletimeout = null;
|
||||
}
|
||||
this.ended = true;
|
||||
@@ -211,12 +211,12 @@ class Collector extends EventEmitter {
|
||||
*/
|
||||
resetTimer({ time, idle } = {}) {
|
||||
if (this._timeout) {
|
||||
this.client.clearTimeout(this._timeout);
|
||||
this._timeout = this.client.setTimeout(() => this.stop('time'), time ?? this.options.time);
|
||||
clearTimeout(this._timeout);
|
||||
this._timeout = setTimeout(() => this.stop('time'), time ?? this.options.time).unref();
|
||||
}
|
||||
if (this._idletimeout) {
|
||||
this.client.clearTimeout(this._idletimeout);
|
||||
this._idletimeout = this.client.setTimeout(() => this.stop('idle'), idle ?? this.options.idle);
|
||||
clearTimeout(this._idletimeout);
|
||||
this._idletimeout = setTimeout(() => this.stop('idle'), idle ?? this.options.idle).unref();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user