makeCache and sweepers Client Options

I have some questions related to this, one of them is the GuildMessages automatically caches all messages? and how does makeCache and sweepers exactly work? I don't really have problems with RAM but I would like to make my bot as performant as possible
10 Replies
d.js toolkit
d.js toolkit•7mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Squid
Squid•7mo ago
the GuildMessages automatically caches all messages?
Yes, messages are cached when DJS receives them from the API, and they're automatically received if you have that intent The cache options have a guide section here, but do tell if you need more clarification: https://discordjs.guide/miscellaneous/cache-customization.html#limiting-caches
discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
-Carlos👑
-Carlos👑•7mo ago
Is there any list of all managers I can limit?
Squid
Squid•7mo ago
Here's what the typings point toward:
export interface Caches {
AutoModerationRuleManager: [manager: typeof AutoModerationRuleManager, holds: typeof AutoModerationRule];
ApplicationCommandManager: [manager: typeof ApplicationCommandManager, holds: typeof ApplicationCommand];
BaseGuildEmojiManager: [manager: typeof BaseGuildEmojiManager, holds: typeof GuildEmoji];
DMMessageManager: [manager: typeof MessageManager, holds: typeof Message<false>];
GuildEmojiManager: [manager: typeof GuildEmojiManager, holds: typeof GuildEmoji];
// TODO: ChannelManager: [manager: typeof ChannelManager, holds: typeof Channel];
// TODO: GuildChannelManager: [manager: typeof GuildChannelManager, holds: typeof GuildChannel];
// TODO: GuildManager: [manager: typeof GuildManager, holds: typeof Guild];
GuildMemberManager: [manager: typeof GuildMemberManager, holds: typeof GuildMember];
GuildBanManager: [manager: typeof GuildBanManager, holds: typeof GuildBan];
GuildForumThreadManager: [manager: typeof GuildForumThreadManager, holds: typeof ThreadChannel<true>];
GuildInviteManager: [manager: typeof GuildInviteManager, holds: typeof Invite];
GuildMessageManager: [manager: typeof GuildMessageManager, holds: typeof Message<true>];
GuildScheduledEventManager: [manager: typeof GuildScheduledEventManager, holds: typeof GuildScheduledEvent];
GuildStickerManager: [manager: typeof GuildStickerManager, holds: typeof Sticker];
GuildTextThreadManager: [manager: typeof GuildTextThreadManager, holds: typeof ThreadChannel<false>];
MessageManager: ...
// TODO: PermissionOverwriteManager: [manager: typeof PermissionOverwriteManager, holds: typeof PermissionOverwrites];
PresenceManager: ...
ReactionManager: ...
ReactionUserManager: ...;
// TODO: RoleManager: [manager: typeof RoleManager, holds: typeof Role];
StageInstanceManager: ...;
ThreadManager: ...;
ThreadMemberManager: ...;
UserManager: ...;
VoiceStateManager: ...;
}
export interface Caches {
AutoModerationRuleManager: [manager: typeof AutoModerationRuleManager, holds: typeof AutoModerationRule];
ApplicationCommandManager: [manager: typeof ApplicationCommandManager, holds: typeof ApplicationCommand];
BaseGuildEmojiManager: [manager: typeof BaseGuildEmojiManager, holds: typeof GuildEmoji];
DMMessageManager: [manager: typeof MessageManager, holds: typeof Message<false>];
GuildEmojiManager: [manager: typeof GuildEmojiManager, holds: typeof GuildEmoji];
// TODO: ChannelManager: [manager: typeof ChannelManager, holds: typeof Channel];
// TODO: GuildChannelManager: [manager: typeof GuildChannelManager, holds: typeof GuildChannel];
// TODO: GuildManager: [manager: typeof GuildManager, holds: typeof Guild];
GuildMemberManager: [manager: typeof GuildMemberManager, holds: typeof GuildMember];
GuildBanManager: [manager: typeof GuildBanManager, holds: typeof GuildBan];
GuildForumThreadManager: [manager: typeof GuildForumThreadManager, holds: typeof ThreadChannel<true>];
GuildInviteManager: [manager: typeof GuildInviteManager, holds: typeof Invite];
GuildMessageManager: [manager: typeof GuildMessageManager, holds: typeof Message<true>];
GuildScheduledEventManager: [manager: typeof GuildScheduledEventManager, holds: typeof GuildScheduledEvent];
GuildStickerManager: [manager: typeof GuildStickerManager, holds: typeof Sticker];
GuildTextThreadManager: [manager: typeof GuildTextThreadManager, holds: typeof ThreadChannel<false>];
MessageManager: ...
// TODO: PermissionOverwriteManager: [manager: typeof PermissionOverwriteManager, holds: typeof PermissionOverwrites];
PresenceManager: ...
ReactionManager: ...
ReactionUserManager: ...;
// TODO: RoleManager: [manager: typeof RoleManager, holds: typeof Role];
StageInstanceManager: ...;
ThreadManager: ...;
ThreadMemberManager: ...;
UserManager: ...;
VoiceStateManager: ...;
}
-Carlos👑
-Carlos👑•7mo ago
Also I have a command which gets the reaction count of a message, however it fetches the message before, would limiting ReactionManager to 0 affect this in any way? ty so basically, for example if my bot does nothing related to guild stickers, I can limit it to 0?
Squid
Squid•7mo ago
Yep
-Carlos👑
-Carlos👑•7mo ago
A few questions: About makeCache: Can the bot still create threads with ThreadManager set to 0? Can the bot get the reaction count of a message having ReactionManager set to 0? The message is fetched before About sweepers: Would sweeping messages every hour affect in any way events like messageDelete or messageUpdate? The same with members, if I sweep GuildMember every some time I would need to fetch the member in commands like userinfo?
chewie 🌈
chewie 🌈•7mo ago
yes to makeCache yes to messageDelete and messageUpdate, no to the fetching of members well, not messageDelete necessarily but if the cached message is sweeped, the event wont emit since there is no old message to reference same with guildMemberUpdate if the member isn't cached but for commands the member gets cached upon receiving the event
-Carlos👑
-Carlos👑•7mo ago
alright ty A few other questions: Can the bot still set a status if PresenceManager is set to 0? What's the difference between BaseGuildEmojiManager and GuildEmojiManager and what would happend if I set them to 0 Is there any list where I can see what each of these remove so I don't have to keep asking?
chewie 🌈
chewie 🌈•7mo ago
First of all, they just prevent caching of same named managers. The functionality behind it doesn't change. I dont know the difference between those managers but they clearly prevent emojis from getting cached.