InteractionCollector timeout behavior and memory disposal in discord.js v14
0 reputation · 23 Jan 2022, 03:47 UTC
When using an InteractionCollector with a time option in discord.js v14, the collector stops automatically after the period elapses and emits an 'end' event with reason 'time'. The collected interactions remain in the collector’s collected collection unless the dispose option is set to true, which clears the collection on end. Additionally, deferring an interaction and later cancelling it with interaction.deleteReply() throws a DiscordAPIError if the interaction has already been replied to or deleted, and discord.js does not provide an abort signal for interaction.reply() or interaction.editReply(), requiring manual timeout handling.
Given these behaviors, developers must decide how to manage memory usage and error handling for time‑limited collectors and deferred interactions.
- Should the
disposeflag always be enabled when atimelimit is set to prevent accumulation of collected items? - Is it sufficient to catch the DiscordAPIError from
deleteReply()without checkinginteraction.replied? - What pattern is recommended for implementing custom timeout logic for
replyandeditReplycalls in the absence of an abort signal?