From a29e2074a59a5be4652ff39dbb808047bcc21ae8 Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Wed, 7 Feb 2024 19:38:51 +0100 Subject: [PATCH] ignore if channel is unregistered --- events/channels/voiceStateUpdate.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/events/channels/voiceStateUpdate.js b/events/channels/voiceStateUpdate.js index a48b01b..5ee9841 100644 --- a/events/channels/voiceStateUpdate.js +++ b/events/channels/voiceStateUpdate.js @@ -1,9 +1,18 @@ import { ChannelType, Events, PermissionsBitField } from 'discord.js'; +import { VoiceChannel } from '../../database.js'; export const name = Events.VoiceStateUpdate; export async function execute(_, state) { if (!state.channel) return; + // Find channel by id, return if not registered for customs + const channel = await VoiceChannel.findOne({ + where: { + id: state.channel.id + } + }); + if (channel === null) return; + // Extract user data const member = state.member; const name = member.user.username;