Currently there is no way to tell when a collector with an idle option will end and afaik there is no way to get that information from the timeout itself (there is but it involves using _idleStart and process.uptime() which I don't think is ideal). I also thought about adding a getter that returns the createdTimestamp of the last collected item like @indigo geode suggested but, since collectors are agnostic to what they're collecting, we can't really assume that will always be a thing. The only other alternative I can think of is storing a property of the last timestamp something was collected at in the class itself. Any other suggestions/anyone against this?
#Add a way to know when a collector with idle will end
14 messages · Page 1 of 1 (latest)
Set <Collector>.lastCollectedTimestamp = Date.now() in handleCollect
yes I know how to do it, I'm just making this post to see if anyone is against storing that timestamp there or if there would be other alternatives
What's the use case for this, being able to show a timer for how long it'll still collect or something?
that could be one, but my use case is that I'm listening for other types of interactions inside my collector (i.e. a button collector that shows a modal and waits for it to be submitted back) and I want the time for those to the the same time as the collector itself
ahh right
Wouldn’t this be better implemented by not providing a timer to the other collector but calling .stop() on the second collector in the first collector‘s end event?
Not at all because I have no way of accessing the other collectors in the end event
Then I seem to misunderstand your use case
I have a button collector
When that collector collects something I reply with a modal
I then await the modal to be submitted inside the collector’s collected event
I want the modal collector to wait for as long as the main collector has left
That would be the idle timeout though, since you just collected the button interaction…
In that case yes but I have other cases with more interactions in the way in which the timer would be less than the idle timeout
But then you do have both collectors available in that scope… so you can add an end event handler stopping the other one just fine there, can’t you?
Not quite because I’m using the await methods not actual collectors