mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-03 17:30:07 +00:00
Fix cache plugin doesn't update voice state update (#2388)
* Fix cache plugin doesn't update voice state update * fix putting fix in wrong file * deno fmt * delete voice state * deno fmt Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>
This commit is contained in:
16
plugins/cache/src/setupCacheEdits.ts
vendored
16
plugins/cache/src/setupCacheEdits.ts
vendored
@@ -5,6 +5,7 @@ import type {
|
||||
DiscordMessageReactionAdd,
|
||||
DiscordMessageReactionRemove,
|
||||
DiscordMessageReactionRemoveAll,
|
||||
DiscordVoiceState,
|
||||
} from "../deps.ts";
|
||||
import type { BotWithCache } from "./addCacheCollections.ts";
|
||||
|
||||
@@ -15,6 +16,7 @@ export function setupCacheEdits<B extends Bot>(bot: BotWithCache<B>) {
|
||||
MESSAGE_REACTION_ADD,
|
||||
MESSAGE_REACTION_REMOVE,
|
||||
MESSAGE_REACTION_REMOVE_ALL,
|
||||
VOICE_STATE_UPDATE,
|
||||
} = bot.handlers;
|
||||
|
||||
bot.handlers.GUILD_MEMBER_ADD = function (_, data, shardId) {
|
||||
@@ -116,4 +118,18 @@ export function setupCacheEdits<B extends Bot>(bot: BotWithCache<B>) {
|
||||
|
||||
MESSAGE_REACTION_REMOVE_ALL(bot, data, shardId);
|
||||
};
|
||||
|
||||
bot.handlers.VOICE_STATE_UPDATE = (_, data, shardId) => {
|
||||
const payload = data.d as DiscordVoiceState;
|
||||
if (!payload.guild_id) return;
|
||||
|
||||
const vs = bot.transformers.voiceState(bot, {
|
||||
voiceState: payload,
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
});
|
||||
|
||||
bot.guilds.get(vs.guildId)?.voiceStates.set(vs.userId, vs);
|
||||
|
||||
VOICE_STATE_UPDATE(bot, data, shardId);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user