InteractionCollector is is not being set properly in Quick.DB .sqlite file discord.js

90 views Asked by At

I'm trying to use quick.db for an InteractionCollector manager in discord.js with typescript, and since there can't be more than 1 collector active, whenever a user uses a command that has a collector, it gets set into a map with the user id, and whenever the user uses another command with a collector, the old one gets destroyed.
The problem is, if I use a normal JavaScript map, it works, but since it is heavier I want to use a .sqlite file with quick.db, and when I set the collector, it does not get set entirely, only a sub-object, and since that sub-object does not have the stop function, it gives an error

oldCollector.stop is not a function

Is there a way to fix this, and why does this happen?

Example: This is a collector:

InteractionCollector {
    _events: [Object: null prototype] { end: [Array], collect: [Array] },
    _eventsCount: 2,
    _maxListeners: undefined,
    filter: [AsyncFunction: filter],
    options: {
      filter: [AsyncFunction: filter],
      time: 67709,
      interactionType: 3,
      channel: [TextChannel]
    },
    collected: Collection(0) [Map] {},
    ended: false,
    _timeout: Timeout {
      _idleTimeout: 67709,
      _idlePrev: [TimersList],
      _idleNext: [TimersList],
      _idleStart: 21969,
      _onTimeout: [Function (anonymous)],
      _timerArgs: undefined,
      _repeat: null,
      _destroyed: false,
      [Symbol(refed)]: false,
      [Symbol(kHasPrimitive)]: false,
      [Symbol(asyncId)]: 741,
      [Symbol(triggerId)]: 0
    },
    _idletimeout: null,
    handleCollect: [Function: bound handleCollect] AsyncFunction,
    handleDispose: [Function: bound handleDispose] AsyncFunction,
    messageId: null,
    channelId: '988393091528523816',
    guildId: '988393091067174973',
    interactionType: 'MESSAGE_COMPONENT',
    componentType: null,
    users: Collection(0) [Map] {},
    total: 0,
    empty: [Function: bound empty],
    _handleChannelDeletion: [Function: bound _handleChannelDeletion],
    _handleThreadDeletion: [Function: bound _handleThreadDeletion],
    _handleGuildDeletion: [Function: bound _handleGuildDeletion],
    [Symbol(kCapture)]: false
  }
}

and if I set it with quick.db via db.set(interaction.user.id, collector), it returns this and crashes:

{
      collected: [],
      messageId: null,
      channelId: '988393091528523816',
      guildId: '988393091067174973',
      interactionType: 'MESSAGE_COMPONENT',
      componentType: null,
      users: [],
      total: 0
}

How I set it in the db:

 const collector = interaction.channel.createMessageComponentCollector({
    filter,
    time: utils.rng(50000, 100000),
  });
  collectorMap.set(interaction.user.id, collector);
0

There are 0 answers