mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 10:03:31 +01:00
feat(Collector): Addition of resetTimer() (#3825)
* feat(Collector): Addition of resetTimer() * typings
This commit is contained in:
@@ -188,6 +188,23 @@ class Collector extends EventEmitter {
|
||||
this.emit('end', this.collected, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the collectors timeout and idle timer.
|
||||
* @param {Object} [options] Options
|
||||
* @param {number} [options.time] How long to run the collector for in milliseconds
|
||||
* @param {number} [options.idle] How long to stop the collector after inactivity in milliseconds
|
||||
*/
|
||||
resetTimer({ time, idle } = {}) {
|
||||
if (this._timeout) {
|
||||
this.client.clearTimeout(this._timeout);
|
||||
this._timeout = this.client.setTimeout(() => this.stop('time'), time || this.options.time);
|
||||
}
|
||||
if (this._idletimeout) {
|
||||
this.client.clearTimeout(this._idletimeout);
|
||||
this._idletimeout = this.client.setTimeout(() => this.stop('idle'), idle || this.options.idle);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the collector should end, and if so, ends it.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user