discordjs / discord.js

A powerful JavaScript library for interacting with the Discord API
https://discord.js.org
Apache License 2.0
25.36k stars 3.97k forks source link

Message Sweep not for manually fetched messages #4599

Closed SamuelScheit closed 3 years ago

SamuelScheit commented 4 years ago

I have general conceptional question, no one could help me on the discord server.

You can specify the cache in the client options {messageCacheMaxSize, messageCacheLifetime,messageSweepInterval } so that ram usage doesn't climb indefinitely. But if I set it to one message, does my manual fetched messages for e.g. reaction listeners get sweeped? If yes, add an option to not sweep manually fetched messages.

Thanks!

navi1995 commented 4 years ago

I've also run into this issue, and it's not entirely explained in any guide or documentation that when using awaitReactionCollector and the related events that unwanted behaviour can occur when specific client options are set (removing an active message from cache when it should have events on it). It would be nice to be able to set message.stopSweepable() or some manual logic that stops a message from being swept, and after we're done with the message we can set it to be swept. Or otherwise logging a warning to console if the time for a reactionCollector set is longer than the message cache lifetime.

polypixeldev commented 3 years ago

I also think that something like message.stopSweepable() would be useful to help better manage what you need in the cache. Especially for environments where there isn't a lot of free RAM, the capability to manage your bot's cache is necessary.

Edit: https://github.com/discordjs/discord.js/pull/6013 is making some big changes to being able to customize cache, possibly a way to alternatively implement this could work with this new feature