mirror of
https://github.com/discordjs/discord.js.git
synced 2026-09-17 08:47:27 +00:00
fix: update collector options.time and options.idle in resetTimer (#11534)
* fix(Collector): update options.time and options.idle in resetTimer * fix: apply suggestions from code review Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com> --------- Co-authored-by: Almeida <github@almeidx.dev> Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com>
This commit is contained in:
@@ -272,14 +272,22 @@ class Collector extends AsyncEventEmitter {
|
||||
* @param {CollectorResetTimerOptions} [options] Options for resetting
|
||||
*/
|
||||
resetTimer({ time, idle } = {}) {
|
||||
if (time) {
|
||||
this.options.time = time;
|
||||
}
|
||||
|
||||
if (idle) {
|
||||
this.options.idle = idle;
|
||||
}
|
||||
|
||||
if (this._timeout) {
|
||||
clearTimeout(this._timeout);
|
||||
this._timeout = setTimeout(() => this.stop('time'), time ?? this.options.time).unref();
|
||||
this._timeout = setTimeout(() => this.stop('time'), this.options.time).unref();
|
||||
}
|
||||
|
||||
if (this._idletimeout) {
|
||||
clearTimeout(this._idletimeout);
|
||||
this._idletimeout = setTimeout(() => this.stop('idle'), idle ?? this.options.idle).unref();
|
||||
this._idletimeout = setTimeout(() => this.stop('idle'), this.options.idle).unref();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user