All the power of discord.js, zero caching. This library modifies discord.js's internal classes and functions in order to give you full control over its caching behaviour.
I know that intents are an upcoming feature to the discord API, but I feel like being able to disable specific events is still useful. For example, I have enabled the "GUILDS" intent, but I only listen to the "GUILD_CREATE" event in that intent group, my program wastes resources to process every incoming event that I don't listen to in the "GUILDS" intent group. Since the purpose of this library is to disable caching, there's no actual state managing for guilds if you disable the guild cache (same goes for other caches), so completely ignoring events like "GUILD_UPDATE" is okay.
This PR adds a "disabledEvents" option in the ClientOptions - An array consisting of discord event names to be ignored. It iterates through the array in the function exported from the actions.js file and deletes all the specified events from the PacketHandlers object. I've also updated the typings file.
Tested the PR with the following code: (with and without the disabled events)
const Dlite = require("./client.js");
const client = new Dlite.Client({
cacheChannels:false,
cacheGuilds: true,
cachePresences:false,
cacheRoles:false,
cacheOverwrites:false,
cacheEmojis:false,
disabledEvents: ["ROLE_UPDATE", "CHANNEL_DELETE"]
});
client.on("roleUpdate", () => {
console.log("A role has been updated!");
})
client.on("channelDelete", () => {
console.log("A channel has been deleted!");
});
client.login(...);
The cost of processing these additional events is pretty irrelevant, but still it gives more control to the developer which is one of the goals of this lib. Thanks!
I know that intents are an upcoming feature to the discord API, but I feel like being able to disable specific events is still useful. For example, I have enabled the "GUILDS" intent, but I only listen to the "GUILD_CREATE" event in that intent group, my program wastes resources to process every incoming event that I don't listen to in the "GUILDS" intent group. Since the purpose of this library is to disable caching, there's no actual state managing for guilds if you disable the guild cache (same goes for other caches), so completely ignoring events like "GUILD_UPDATE" is okay.
This PR adds a "disabledEvents" option in the
ClientOptions
- An array consisting of discord event names to be ignored. It iterates through the array in the function exported from theactions.js
file and deletes all the specified events from thePacketHandlers
object. I've also updated the typings file.Tested the PR with the following code: (with and without the disabled events)