Skip to content

Collector#resetTimer does not properly update idle and time options #11286

@7xrrr

Description

@7xrrr

Which package is this bug report for?

discord.js

Issue description

The Collector#resetTimer method does not properly update the collector's timers after changing the idle value. Even after calling resetTimer with a new idle or time, the collector continues to use the old timers. This makes the method ineffective in scenarios where the idle timeout needs to be extended dynamically.

Steps to reproduce

  1. Create a collector with an initial idle time.
  2. Wait some time and then call collector.resetTimer({ idle: newIdleValue }).
  3. Observe that the old idle timer still triggers, and the collector does not reflect the new idle value in collector.options.idle.

Expected behavior

  • The old timers should be cleared.
  • New timers should start based on the updated idle and time values.
  • collector.options.idle and collector.options.time should reflect the new values.

Code sample

const collector = msg.createMessageComponentCollector({
    filter: (i) => i.user.id === author,
    time: 5 * 60_000,  // 5 minutes
    idle: 60_000,      // 1 minute
});

collector.on("collect", async (i: ButtonInteraction | StringSelectMenuInteraction) => {
    // Example: when the "start" button is pressed, attempt to reset timer
    if (i.isButton() && i.customId === "start") {
        const newTime = 15 * 60_000; // 15 minutes
        collector.resetTimer({
            time: newTime,
            idle: newTime,
        });

        // Debug logs
        console.log("Collector timer reset called:");
        console.log("Options.time:", collector.options.time);
        console.log("Options.idle:", collector.options.idle);
    }
});

collector.on("end", (collected, reason) => {
    console.log(`Collector ended: ${reason}`);
});

Versions

  • discord.js version: 14.22.1
  • Node.js version: v20.18.1
  • OS: windows 10

Issue priority

Low (slightly annoying)

Which partials do you have configured?

Channel, Message, GuildMember, User, ThreadMember

Which gateway intents are you subscribing to?

No Intents, Not applicable

I have tested this issue on a development release

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions