diff --git a/.changeset/twelve-avocados-draw.md b/.changeset/twelve-avocados-draw.md new file mode 100644 index 00000000..15086812 --- /dev/null +++ b/.changeset/twelve-avocados-draw.md @@ -0,0 +1,5 @@ +--- +"guilded.js": patch +--- + +fix: stop collecting on time expiration diff --git a/packages/guilded.js/lib/structures/collectors/Collector.ts b/packages/guilded.js/lib/structures/collectors/Collector.ts index 8a447f79..b4fe8a9e 100644 --- a/packages/guilded.js/lib/structures/collectors/Collector.ts +++ b/packages/guilded.js/lib/structures/collectors/Collector.ts @@ -40,7 +40,13 @@ export abstract class Collector { start(): Promise> { return new Promise((resolve) => { this.resolve = resolve; - this.maxTimeout = setTimeout(() => resolve({ reason: CollectorEndReasons.TIME, entries: this.entries }), this.options.timeLimit); + + this.maxTimeout = setTimeout(() => { + this.resolve!({ reason: CollectorEndReasons.TIME, entries: this.entries }); + this._cleanup(); + this.isActive = false; + }, this.options.timeLimit); + this.hookEvents(); this.isActive = true; });