-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetupCacheEdits.ts
More file actions
22 lines (15 loc) · 1.1 KB
/
Copy pathsetupCacheEdits.ts
File metadata and controls
22 lines (15 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { Bot, DiscordGuildMemberAdd, DiscordGuildMemberRemove, type DesiredPropertiesBehavior, type TransformersDesiredProperties } from '@discordeno/bot';
import { BotWithProxyCache, ProxyCacheTypes } from './index.js';
export const setupCacheEdits = <T extends ProxyCacheTypes<Props, Behavior>, Props extends TransformersDesiredProperties, Behavior extends DesiredPropertiesBehavior, B extends Bot<Props, Behavior>>(bot: BotWithProxyCache<T, Props, Behavior, B>) => {
const { GUILD_MEMBER_ADD, GUILD_MEMBER_REMOVE } = bot.handlers;
bot.handlers.GUILD_MEMBER_ADD = async (_, data, shardId) => {
const payload = data.d as DiscordGuildMemberAdd;
bot.cache.options.guildMutators?.incrementMemberCount?.(bot.transformers.snowflake(payload.guild_id));
GUILD_MEMBER_ADD(bot, data, shardId);
};
bot.handlers.GUILD_MEMBER_REMOVE = async (_, data, shardId) => {
const payload = data.d as DiscordGuildMemberRemove;
bot.cache.options.guildMutators?.decrementMemberCount?.(bot.transformers.snowflake(payload.guild_id));
GUILD_MEMBER_REMOVE(bot, data, shardId);
};
};