Skip to content

Commit

Permalink
fix: stop collecting on time expiration (#245)
Browse files Browse the repository at this point in the history
* fix: stop collecting on time expiration

* Create twelve-avocados-draw.md

* chore: prettier
  • Loading branch information
zaida04 authored Oct 24, 2023
1 parent 9cf8ccb commit 102e5a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/twelve-avocados-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"guilded.js": patch
---

fix: stop collecting on time expiration
8 changes: 7 additions & 1 deletion packages/guilded.js/lib/structures/collectors/Collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ export abstract class Collector<T extends CollectableStructure> {
start(): Promise<CollectorReturnValue<T>> {
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;
});
Expand Down

0 comments on commit 102e5a8

Please sign in to comment.