mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-03 09:20:08 +00:00
fix: handle undef Guild#voiceStates
This commit is contained in:
@@ -28,12 +28,12 @@ export async function handleInternalChannelDelete(data: DiscordPayload) {
|
||||
if (cachedChannel.type === ChannelTypes.GUILD_VOICE && payload.guild_id) {
|
||||
const guild = await cacheHandlers.get("guilds", payload.guild_id);
|
||||
|
||||
if (guild) {
|
||||
if (guild && guild.voiceStates) {
|
||||
return Promise.all(guild.voiceStates.map(async (vs, key) => {
|
||||
if (vs.channelID !== payload.id) return;
|
||||
|
||||
// Since this channel was deleted all voice states for this channel should be deleted
|
||||
guild.voiceStates.delete(key);
|
||||
guild.voiceStates?.delete(key);
|
||||
|
||||
const member = await cacheHandlers.get("members", vs.userID);
|
||||
if (!member) return;
|
||||
|
||||
@@ -97,9 +97,9 @@ export async function handleInternalVoiceStateUpdate(data: DiscordPayload) {
|
||||
if (!member) return;
|
||||
|
||||
// No cached state before so lets make one for em
|
||||
const cachedState = guild.voiceStates.get(payload.user_id);
|
||||
const cachedState = guild.voiceStates?.get(payload.user_id);
|
||||
|
||||
guild.voiceStates.set(payload.user_id, {
|
||||
guild.voiceStates?.set(payload.user_id, {
|
||||
...payload,
|
||||
guildID: payload.guild_id,
|
||||
channelID: payload.channel_id || "",
|
||||
@@ -124,7 +124,7 @@ export async function handleInternalVoiceStateUpdate(data: DiscordPayload) {
|
||||
}
|
||||
} // Left the channel
|
||||
else if (cachedState?.channelID) {
|
||||
guild.voiceStates.delete(payload.user_id);
|
||||
guild.voiceStates?.delete(payload.user_id);
|
||||
eventHandlers.voiceChannelLeave?.(member, cachedState.channelID);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user