mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 16:57:22 +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:
co-authored by
Skillz4Killz
parent
b89d3ca078
commit
1ea2a81363
Vendored
+16
@@ -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);
|
||||
};
|
||||
}
|
||||
|
||||
+18
-2
@@ -1,5 +1,4 @@
|
||||
import type { Emoji, Guild } from "../deps.ts";
|
||||
import type { BotWithCache } from "./addCacheCollections.ts";
|
||||
import type { Emoji } from "../deps.ts";
|
||||
import {
|
||||
Bot,
|
||||
Collection,
|
||||
@@ -11,7 +10,9 @@ import {
|
||||
DiscordMessageDelete,
|
||||
DiscordMessageDeleteBulk,
|
||||
DiscordUnavailableGuild,
|
||||
DiscordVoiceState,
|
||||
} from "../deps.ts";
|
||||
import type { BotWithCache } from "./addCacheCollections.ts";
|
||||
|
||||
export function setupCacheRemovals<B extends Bot>(bot: BotWithCache<B>) {
|
||||
const {
|
||||
@@ -22,6 +23,7 @@ export function setupCacheRemovals<B extends Bot>(bot: BotWithCache<B>) {
|
||||
GUILD_MEMBER_REMOVE,
|
||||
GUILD_ROLE_DELETE,
|
||||
MESSAGE_DELETE_BULK,
|
||||
VOICE_STATE_UPDATE,
|
||||
} = bot.handlers;
|
||||
|
||||
bot.handlers.GUILD_DELETE = function (_, data, shardId) {
|
||||
@@ -118,4 +120,18 @@ export function setupCacheRemovals<B extends Bot>(bot: BotWithCache<B>) {
|
||||
|
||||
GUILD_ROLE_DELETE(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),
|
||||
});
|
||||
|
||||
if (!vs.channelId) bot.guilds.get(vs.guildId)?.voiceStates.delete(vs.userId);
|
||||
|
||||
VOICE_STATE_UPDATE(bot, data, shardId);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user