ignore if channel is unregistered

This commit is contained in:
Baipyrus 2024-02-07 19:38:51 +01:00
parent d212ca398a
commit a29e2074a5

View File

@ -1,9 +1,18 @@
import { ChannelType, Events, PermissionsBitField } from 'discord.js'; import { ChannelType, Events, PermissionsBitField } from 'discord.js';
import { VoiceChannel } from '../../database.js';
export const name = Events.VoiceStateUpdate; export const name = Events.VoiceStateUpdate;
export async function execute(_, state) { export async function execute(_, state) {
if (!state.channel) return; 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 // Extract user data
const member = state.member; const member = state.member;
const name = member.user.username; const name = member.user.username;