diff --git a/src/BaseClient/Bot/Cache/automod.ts b/src/BaseClient/Bot/Cache/automod.ts index 5229db3e..cbe7f97c 100644 --- a/src/BaseClient/Bot/Cache/automod.ts +++ b/src/BaseClient/Bot/Cache/automod.ts @@ -42,10 +42,9 @@ export default class AutomodCache extends Cache { return this.redis.get(`${this.key()}:${id}`).then((data) => this.stringToData(data)); } - del(id: string): Promise { - return this.redis - .keys(`${this.key()}:${id}`) - .then((keys) => (keys.length ? this.redis.del(keys) : 0)); + async del(id: string): Promise { + const keys = await Cache.scanKeys(`${this.key()}:${id}`); + return keys.length ? this.redis.del(keys) : 0; } apiToR(data: APIAutoModerationRule) { diff --git a/src/BaseClient/Bot/Cache/base.ts b/src/BaseClient/Bot/Cache/base.ts index 93b4eb26..06eeda04 100644 --- a/src/BaseClient/Bot/Cache/base.ts +++ b/src/BaseClient/Bot/Cache/base.ts @@ -23,6 +23,7 @@ import type { APIWebhook, } from 'discord-api-types/v10'; import type Redis from 'ioredis'; +import scanKeys from '../../UtilModules/scanKeys.js'; import type { RAutomod } from './automod'; import type { RBan } from './ban'; import type { RChannel, RChannelTypes } from './channel'; @@ -155,6 +156,10 @@ export default abstract class Cache< return `${this.prefix}${id ? `:${id}` : '*'}`; } + static async scanKeys(pattern: string): Promise { + return scanKeys(pattern); + } + abstract set(...args: [T, string, string, string]): Promise; abstract get(...args: string[]): Promise>; abstract del(...args: string[]): Promise; diff --git a/src/BaseClient/Bot/Cache/channel.ts b/src/BaseClient/Bot/Cache/channel.ts index fa74c8b7..3fa395ea 100644 --- a/src/BaseClient/Bot/Cache/channel.ts +++ b/src/BaseClient/Bot/Cache/channel.ts @@ -74,10 +74,9 @@ export default class ChannelCache extends Cache< return this.redis.get(`${this.key()}:${id}`).then((data) => this.stringToData(data)); } - del(id: string): Promise { - return this.redis - .keys(`${this.key()}:${id}`) - .then((keys) => (keys.length ? this.redis.del(keys) : 0)); + async del(id: string): Promise { + const keys = await Cache.scanKeys(`${this.key()}:${id}`); + return keys.length ? this.redis.del(keys) : 0; } apiToR(data: APIGuildChannel) { diff --git a/src/BaseClient/Bot/Cache/commandPermission.ts b/src/BaseClient/Bot/Cache/commandPermission.ts index b304b0d6..03624187 100644 --- a/src/BaseClient/Bot/Cache/commandPermission.ts +++ b/src/BaseClient/Bot/Cache/commandPermission.ts @@ -30,10 +30,9 @@ export default class CommandPermissionCache extends Cache this.stringToData(data)); } - del(id: string): Promise { - return this.redis - .keys(`${this.key()}:${id}`) - .then((keys) => (keys.length ? this.redis.del(keys) : 0)); + async del(id: string): Promise { + const keys = await Cache.scanKeys(`${this.key()}:${id}`); + return keys.length ? this.redis.del(keys) : 0; } apiToR(data: APIApplicationCommandPermission, guildId: string) { diff --git a/src/BaseClient/Bot/Cache/emoji.ts b/src/BaseClient/Bot/Cache/emoji.ts index 396dd719..f6a0d5af 100644 --- a/src/BaseClient/Bot/Cache/emoji.ts +++ b/src/BaseClient/Bot/Cache/emoji.ts @@ -39,10 +39,9 @@ export default class EmojiCache extends Cache { return this.redis.get(`${this.key()}:${id}`).then((data) => this.stringToData(data)); } - del(id: string): Promise { - return this.redis - .keys(`${this.key()}:${id}`) - .then((keys) => (keys.length ? this.redis.del(keys) : 0)); + async del(id: string): Promise { + const keys = await Cache.scanKeys(`${this.key()}:${id}`); + return keys.length ? this.redis.del(keys) : 0; } apiToR(data: APIEmoji, guildId: string) { diff --git a/src/BaseClient/Bot/Cache/event.ts b/src/BaseClient/Bot/Cache/event.ts index ddb3d9fd..ee843af9 100644 --- a/src/BaseClient/Bot/Cache/event.ts +++ b/src/BaseClient/Bot/Cache/event.ts @@ -55,10 +55,9 @@ export default class EventCache extends Cache { return this.redis.get(`${this.key()}:${id}`).then((data) => this.stringToData(data)); } - del(id: string): Promise { - return this.redis - .keys(`${this.key()}:${id}`) - .then((keys) => (keys.length ? this.redis.del(keys) : 0)); + async del(id: string): Promise { + const keys = await Cache.scanKeys(`${this.key()}:${id}`); + return keys.length ? this.redis.del(keys) : 0; } apiToR(data: APIGuildScheduledEvent) { diff --git a/src/BaseClient/Bot/Cache/guildCommand.ts b/src/BaseClient/Bot/Cache/guildCommand.ts index 9b7f392a..b1db0c82 100644 --- a/src/BaseClient/Bot/Cache/guildCommand.ts +++ b/src/BaseClient/Bot/Cache/guildCommand.ts @@ -54,10 +54,9 @@ export default class GuildCommandCache extends Cache< return this.redis.get(`${this.key()}:${gId}:${id}`).then((data) => this.stringToData(data)); } - del(id: string): Promise { - return this.redis - .keys(`${this.key()}:${id}`) - .then((keys) => (keys.length ? this.redis.del(keys) : 0)); + async del(id: string): Promise { + const keys = await Cache.scanKeys(`${this.key()}:${id}`); + return keys.length ? this.redis.del(keys) : 0; } // eslint-disable-next-line class-methods-use-this diff --git a/src/BaseClient/Bot/Cache/integration.ts b/src/BaseClient/Bot/Cache/integration.ts index fed1a1d2..ef0ae65c 100644 --- a/src/BaseClient/Bot/Cache/integration.ts +++ b/src/BaseClient/Bot/Cache/integration.ts @@ -50,10 +50,9 @@ export default class IntegrationCache extends Cache< return this.redis.get(`${this.key()}:${id}`).then((data) => this.stringToData(data)); } - del(id: string): Promise { - return this.redis - .keys(`${this.key()}:${id}`) - .then((keys) => (keys.length ? this.redis.del(keys) : 0)); + async del(id: string): Promise { + const keys = await Cache.scanKeys(`${this.key()}:${id}`); + return keys.length ? this.redis.del(keys) : 0; } apiToR(data: APIGuildIntegration, guildId: string) { diff --git a/src/BaseClient/Bot/Cache/invite.ts b/src/BaseClient/Bot/Cache/invite.ts index 291f7f22..5371755a 100644 --- a/src/BaseClient/Bot/Cache/invite.ts +++ b/src/BaseClient/Bot/Cache/invite.ts @@ -53,10 +53,9 @@ export default class InviteCache extends Cache { return this.redis.get(`${this.key()}:${code}`).then((data) => this.stringToData(data)); } - del(code: string): Promise { - return this.redis - .keys(`${this.key()}:${code}`) - .then((keys) => (keys.length ? this.redis.del(keys) : 0)); + async del(code: string): Promise { + const keys = await Cache.scanKeys(`${this.key()}:${code}`); + return keys.length ? this.redis.del(keys) : 0; } apiToR(data: APIInvite) { diff --git a/src/BaseClient/Bot/Cache/message.ts b/src/BaseClient/Bot/Cache/message.ts index 0843ab53..c984efa9 100644 --- a/src/BaseClient/Bot/Cache/message.ts +++ b/src/BaseClient/Bot/Cache/message.ts @@ -82,10 +82,9 @@ export default class MessageCache extends Cache { return this.redis.get(`${this.key()}:${id}`).then((data) => this.stringToData(data)); } - del(id: string): Promise { - return this.redis - .keys(`${this.key()}:${id}`) - .then((keys) => (keys.length ? this.redis.del(keys) : 0)); + async del(id: string): Promise { + const keys = await Cache.scanKeys(`${this.key()}:${id}`); + return keys.length ? this.redis.del(keys) : 0; } apiToR(data: APIMessage, guildId: string) { diff --git a/src/BaseClient/Bot/Cache/reaction.ts b/src/BaseClient/Bot/Cache/reaction.ts index 04e96204..cae98a35 100644 --- a/src/BaseClient/Bot/Cache/reaction.ts +++ b/src/BaseClient/Bot/Cache/reaction.ts @@ -42,10 +42,9 @@ export default class ReactionCache extends Cache { return this.redis.get(`${this.key()}:${mId}:${eId}`).then((data) => this.stringToData(data)); } - del(mId: string, eId: string): Promise { - return this.redis - .keys(`${this.key()}:${mId}:${eId}`) - .then((keys) => (keys.length ? this.redis.del(keys) : 0)); + async del(mId: string, eId: string): Promise { + const keys = await Cache.scanKeys(`${this.key()}:${mId}:${eId}`); + return keys.length ? this.redis.del(keys) : 0; } apiToR(data: APIReaction, guildId: string, channelId: string, messageId: string) { diff --git a/src/BaseClient/Bot/Cache/role.ts b/src/BaseClient/Bot/Cache/role.ts index 09a61784..76ae58bd 100644 --- a/src/BaseClient/Bot/Cache/role.ts +++ b/src/BaseClient/Bot/Cache/role.ts @@ -48,10 +48,9 @@ export default class RoleCache extends Cache { return this.redis.get(`${this.key()}:${id}`).then((data) => this.stringToData(data)); } - del(id: string): Promise { - return this.redis - .keys(`${this.key()}:${id}`) - .then((keys) => (keys.length ? this.redis.del(keys) : 0)); + async del(id: string): Promise { + const keys = await Cache.scanKeys(`${this.key()}:${id}`); + return keys.length ? this.redis.del(keys) : 0; } apiToR(data: APIRole, guildId: string) { diff --git a/src/BaseClient/Bot/Cache/soundboard.ts b/src/BaseClient/Bot/Cache/soundboard.ts index 6bcc18c3..9500d1a4 100644 --- a/src/BaseClient/Bot/Cache/soundboard.ts +++ b/src/BaseClient/Bot/Cache/soundboard.ts @@ -39,10 +39,9 @@ export default class SoundboardCache extends Cache { return this.redis.get(`${this.key()}:${id}`).then((data) => this.stringToData(data)); } - del(id: string): Promise { - return this.redis - .keys(`${this.key()}:${id}`) - .then((keys) => (keys.length ? this.redis.del(keys) : 0)); + async del(id: string): Promise { + const keys = await Cache.scanKeys(`${this.key()}:${id}`); + return keys.length ? this.redis.del(keys) : 0; } apiToR(data: APISoundboardSound) { diff --git a/src/BaseClient/Bot/Cache/stage.ts b/src/BaseClient/Bot/Cache/stage.ts index d5f15060..2da8f60c 100644 --- a/src/BaseClient/Bot/Cache/stage.ts +++ b/src/BaseClient/Bot/Cache/stage.ts @@ -38,10 +38,9 @@ export default class StageCache extends Cache { return this.redis.get(`${this.key()}:${id}`).then((data) => this.stringToData(data)); } - del(id: string): Promise { - return this.redis - .keys(`${this.key()}:${id}`) - .then((keys) => (keys.length ? this.redis.del(keys) : 0)); + async del(id: string): Promise { + const keys = await Cache.scanKeys(`${this.key()}:${id}`); + return keys.length ? this.redis.del(keys) : 0; } apiToR(data: APIStageInstance) { diff --git a/src/BaseClient/Bot/Cache/sticker.ts b/src/BaseClient/Bot/Cache/sticker.ts index 06bd9384..d944bcf7 100644 --- a/src/BaseClient/Bot/Cache/sticker.ts +++ b/src/BaseClient/Bot/Cache/sticker.ts @@ -42,10 +42,9 @@ export default class StickerCache extends Cache { return this.redis.get(`${this.key()}:${id}`).then((data) => this.stringToData(data)); } - del(id: string): Promise { - return this.redis - .keys(`${this.key()}:${id}`) - .then((keys) => (keys.length ? this.redis.del(keys) : 0)); + async del(id: string): Promise { + const keys = await Cache.scanKeys(`${this.key()}:${id}`); + return keys.length ? this.redis.del(keys) : 0; } apiToR(data: APISticker) { diff --git a/src/BaseClient/Bot/Cache/thread.ts b/src/BaseClient/Bot/Cache/thread.ts index be055073..4d7f9290 100644 --- a/src/BaseClient/Bot/Cache/thread.ts +++ b/src/BaseClient/Bot/Cache/thread.ts @@ -67,10 +67,9 @@ export default class ThreadCache extends Cache< return this.redis.get(`${this.key()}:${id}`).then((data) => this.stringToData(data)); } - del(id: string): Promise { - return this.redis - .keys(`${this.key()}:${id}`) - .then((keys) => (keys.length ? this.redis.del(keys) : 0)); + async del(id: string): Promise { + const keys = await Cache.scanKeys(`${this.key()}:${id}`); + return keys.length ? this.redis.del(keys) : 0; } apiToR(data: Omit) { diff --git a/src/BaseClient/Bot/Cache/threadMember.ts b/src/BaseClient/Bot/Cache/threadMember.ts index 41604c2f..6365c72f 100644 --- a/src/BaseClient/Bot/Cache/threadMember.ts +++ b/src/BaseClient/Bot/Cache/threadMember.ts @@ -37,10 +37,9 @@ export default class ThreadMemberCache extends Cache { return this.redis.get(`${this.key()}:${tId}:${id}`).then((data) => this.stringToData(data)); } - del(tId: string, id: string): Promise { - return this.redis - .keys(`${this.key()}:${tId}:${id}`) - .then((keys) => (keys.length ? this.redis.del(keys) : 0)); + async del(tId: string, id: string): Promise { + const keys = await Cache.scanKeys(`${this.key()}:${tId}${id}`); + return keys.length ? this.redis.del(keys) : 0; } apiToR(data: APIThreadMember, guildId: string) { diff --git a/src/BaseClient/Bot/Cache/webhook.ts b/src/BaseClient/Bot/Cache/webhook.ts index 797c3e39..1e8bf9ea 100644 --- a/src/BaseClient/Bot/Cache/webhook.ts +++ b/src/BaseClient/Bot/Cache/webhook.ts @@ -55,10 +55,9 @@ export default class WebhookCache extends Cache< return this.redis.get(`${this.key()}:${id}`).then((data) => this.stringToData(data)); } - del(id: string): Promise { - return this.redis - .keys(`${this.key()}:${id}`) - .then((keys) => (keys.length ? this.redis.del(keys) : 0)); + async del(id: string): Promise { + const keys = await Cache.scanKeys(`${this.key()}:${id}`); + return keys.length ? this.redis.del(keys) : 0; } apiToR(data: APIWebhook) { diff --git a/src/BaseClient/Bot/Redis.ts b/src/BaseClient/Bot/Redis.ts index 03d131d7..9d5eee41 100644 --- a/src/BaseClient/Bot/Redis.ts +++ b/src/BaseClient/Bot/Redis.ts @@ -33,7 +33,6 @@ const subscriber = new Redis({ host: 'redis', db }); export default redis; export const prefix = `${process.env.mainId}:cache`; -await redis.keys(`${prefix}:*`).then((r) => (r.length ? redis.del(r) : 0)); await redis.config('SET', 'notify-keyspace-events', 'Ex'); await subscriber.subscribe(`__keyevent@${db}__:expired`); diff --git a/src/BaseClient/Bot/Util.ts b/src/BaseClient/Bot/Util.ts index fa297ee6..94df754f 100644 --- a/src/BaseClient/Bot/Util.ts +++ b/src/BaseClient/Bot/Util.ts @@ -102,6 +102,7 @@ import getScheduled from '../UtilModules/getScheduled.js'; import delScheduled from '../UtilModules/delScheduled.js'; import setRatelimit from '../UtilModules/setRatelimit.js'; import getRatelimit from '../UtilModules/getRatelimit.js'; +import scanKeys from '../UtilModules/scanKeys.js'; const logFiles = { ratelimits: fs.createWriteStream( @@ -212,6 +213,7 @@ interface Util { delScheduled: typeof delScheduled; setRatelimit: typeof setRatelimit; getRatelimit: typeof getRatelimit; + scanKeys: typeof scanKeys; } const util: Util = { @@ -316,6 +318,7 @@ const util: Util = { delScheduled, setRatelimit, getRatelimit, + scanKeys, }; export default util; diff --git a/src/BaseClient/UtilModules/delScheduled.ts b/src/BaseClient/UtilModules/delScheduled.ts index ce769607..1ca3a2b1 100644 --- a/src/BaseClient/UtilModules/delScheduled.ts +++ b/src/BaseClient/UtilModules/delScheduled.ts @@ -1,8 +1,9 @@ import Redis from '../Bot/Redis.js'; import { prefix } from './getScheduled.js'; +import scanKeys from './scanKeys.js'; export default async (key: string) => { - const keys = await Redis.keys(`${prefix}:${key}`); + const keys = await scanKeys(`${prefix}:${key}`); if (!keys.length) return; const allKeys = [...keys, ...keys.map((k) => k.replace('scheduled', 'scheduled-data'))]; diff --git a/src/BaseClient/UtilModules/scanKeys.ts b/src/BaseClient/UtilModules/scanKeys.ts new file mode 100644 index 00000000..23ffc124 --- /dev/null +++ b/src/BaseClient/UtilModules/scanKeys.ts @@ -0,0 +1,15 @@ +import redis from '../Bot/Redis.js'; + +export default async (pattern: string) => { + const keys: string[] = []; + let cursor = '0'; + + do { + // eslint-disable-next-line no-await-in-loop + const [nextCursor, scanKeys] = await redis.scan(cursor, 'MATCH', pattern, 'COUNT', '100'); + cursor = nextCursor; + keys.push(...scanKeys); + } while (cursor !== '0'); + + return keys; +}; diff --git a/src/Events/BotEvents/messageEvents/messageCreate/votePunish.ts b/src/Events/BotEvents/messageEvents/messageCreate/votePunish.ts index 965d5bf9..003a00f0 100644 --- a/src/Events/BotEvents/messageEvents/messageCreate/votePunish.ts +++ b/src/Events/BotEvents/messageEvents/messageCreate/votePunish.ts @@ -1,5 +1,4 @@ import type { Message } from 'discord.js'; -import redis from '../../../../BaseClient/Bot/Redis.js'; import { prefix } from '../../../../BaseClient/UtilModules/getScheduled.js'; export default async (msg: Message) => { @@ -14,7 +13,9 @@ export default async (msg: Message) => { if (!msg.mentions.roles.size) return; - if ((await redis.keys(`${prefix}:votePunish:${msg.guildId}:*:${msg.channelId}`)).length) { + if ( + (await msg.client.util.scanKeys(`${prefix}:votePunish:${msg.guildId}:*:${msg.channelId}`)).length + ) { return; } diff --git a/src/Events/BotEvents/raw/Cache/Channel.ts b/src/Events/BotEvents/raw/Cache/Channel.ts index ba507042..8e53b440 100644 --- a/src/Events/BotEvents/raw/Cache/Channel.ts +++ b/src/Events/BotEvents/raw/Cache/Channel.ts @@ -7,6 +7,7 @@ import { type GatewayChannelUpdateDispatchData, } from 'discord.js'; import RedisClient, { cache as redis } from '../../../../BaseClient/Bot/Redis.js'; +import scanKeys from '../../../../BaseClient/UtilModules/scanKeys.js'; export default { [GatewayDispatchEvents.ChannelCreate]: (data: GatewayChannelCreateDispatchData) => @@ -14,7 +15,7 @@ export default { [GatewayDispatchEvents.ChannelDelete]: (data: GatewayChannelDeleteDispatchData) => { redis.channels.del(data.id); - RedisClient.keys(`${redis.messages.key}:${data.guild_id}:${data.id}:*`).then((keys) => + scanKeys(`${redis.messages.key()}:${data.guild_id}:${data.id}:*`).then((keys) => keys.length ? RedisClient.del(keys) : 0, ); }, diff --git a/src/Events/BotEvents/raw/Cache/Guilds.ts b/src/Events/BotEvents/raw/Cache/Guilds.ts index 7f79c1da..e570a2a4 100644 --- a/src/Events/BotEvents/raw/Cache/Guilds.ts +++ b/src/Events/BotEvents/raw/Cache/Guilds.ts @@ -31,6 +31,7 @@ import RedisClient, { cache as redis, prefix as redisKey, } from '../../../../BaseClient/Bot/Redis.js'; +import scanKeys from '../../../../BaseClient/UtilModules/scanKeys.js'; export default { [GatewayDispatchEvents.GuildAuditLogEntryCreate]: ( @@ -64,13 +65,13 @@ export default { }, [GatewayDispatchEvents.GuildDelete]: (data: GatewayGuildDeleteDispatchData) => - RedisClient.keys(`${redisKey}:${data.id}:*`).then((r) => (r.length ? RedisClient.del(r) : 0)), + scanKeys(`${redisKey}:${data.id}:*`).then((r) => (r.length ? RedisClient.del(r) : 0)), [GatewayDispatchEvents.GuildUpdate]: (data: GatewayGuildUpdateDispatchData) => redis.guilds.set(data), [GatewayDispatchEvents.GuildEmojisUpdate]: async (data: GatewayGuildEmojisUpdateDispatchData) => { - await RedisClient.keys(`${redis.emojis.key()}:${data.guild_id}:*`).then((r) => + await scanKeys(`${redis.emojis.key()}:${data.guild_id}:*`).then((r) => r.length ? RedisClient.del(r) : 0, ); @@ -177,7 +178,7 @@ export default { [GatewayDispatchEvents.GuildSoundboardSoundsUpdate]: async ( data: GatewayGuildSoundboardSoundsUpdateDispatchData, ) => { - await RedisClient.keys(`${redis.soundboards.key()}:${data.guild_id}:*`).then((r) => + await scanKeys(`${redis.soundboards.key()}:${data.guild_id}:*`).then((r) => r.length ? RedisClient.del(r) : 0, ); @@ -189,7 +190,7 @@ export default { [GatewayDispatchEvents.GuildStickersUpdate]: async ( data: GatewayGuildStickersUpdateDispatchData, ) => { - await RedisClient.keys(`${redis.stickers.key()}:${data.guild_id}:*`).then((r) => + await scanKeys(`${redis.stickers.key()}:${data.guild_id}:*`).then((r) => r.length ? RedisClient.del(r) : 0, ); diff --git a/src/Events/BotEvents/raw/Cache/Message.ts b/src/Events/BotEvents/raw/Cache/Message.ts index a0912cd5..1a1aab22 100644 --- a/src/Events/BotEvents/raw/Cache/Message.ts +++ b/src/Events/BotEvents/raw/Cache/Message.ts @@ -11,8 +11,9 @@ import { type GatewayMessageReactionRemoveEmojiDispatchData, type GatewayMessageUpdateDispatchData, } from 'discord.js'; -import { AllThreadGuildChannelTypes } from '../../../../Typings/Channel.js'; import RedisClient, { cache as redis } from '../../../../BaseClient/Bot/Redis.js'; +import scanKeys from '../../../../BaseClient/UtilModules/scanKeys.js'; +import { AllThreadGuildChannelTypes } from '../../../../Typings/Channel.js'; export default { [GatewayDispatchEvents.MessageCreate]: async (data: GatewayMessageCreateDispatchData) => { @@ -102,14 +103,14 @@ export default { [GatewayDispatchEvents.MessageReactionRemoveAll]: ( data: GatewayMessageReactionRemoveAllDispatchData, ) => - RedisClient.keys(`${redis.reactions.key()}:*:${data.message_id}:*`).then((r) => + scanKeys(`${redis.reactions.key()}:*:${data.message_id}:*`).then((r) => r.length ? RedisClient.del(r) : 0, ), [GatewayDispatchEvents.MessageReactionRemoveEmoji]: ( data: GatewayMessageReactionRemoveEmojiDispatchData, ) => - RedisClient.keys( + scanKeys( `${redis.reactions.key()}:*:${data.message_id}:${data.emoji.id || data.emoji.name}`, ).then((r) => (r.length ? RedisClient.del(r) : 0)), } as const; diff --git a/src/Events/BotEvents/raw/Cache/Thread.ts b/src/Events/BotEvents/raw/Cache/Thread.ts index 51cdc192..c88e78f9 100644 --- a/src/Events/BotEvents/raw/Cache/Thread.ts +++ b/src/Events/BotEvents/raw/Cache/Thread.ts @@ -9,6 +9,7 @@ import { type GatewayThreadUpdateDispatchData, } from 'discord.js'; import RedisClient, { cache as redis } from '../../../../BaseClient/Bot/Redis.js'; +import scanKeys from '../../../../BaseClient/UtilModules/scanKeys.js'; export default { [GatewayDispatchEvents.ThreadCreate]: (data: GatewayThreadCreateDispatchData) => @@ -17,11 +18,11 @@ export default { [GatewayDispatchEvents.ThreadDelete]: (data: GatewayThreadDeleteDispatchData) => { redis.threads.del(data.id); - RedisClient.keys(`${redis.messages.key}:${data.guild_id}:${data.id}:*`).then((keys) => + scanKeys(`${redis.messages.key}:${data.guild_id}:${data.id}:*`).then((keys) => keys.length ? RedisClient.del(keys) : 0, ); - RedisClient.keys(`${redis.threadMembers.key}:${data.guild_id}:${data.id}:*`).then((keys) => + scanKeys(`${redis.threadMembers.key}:${data.guild_id}:${data.id}:*`).then((keys) => keys.length ? RedisClient.del(keys) : 0, ); },