From 1d11005a6b95a05131a56872ad0b2e7f25a550a8 Mon Sep 17 00:00:00 2001 From: SandwichBtw Date: Sun, 26 Nov 2023 22:58:19 +0100 Subject: [PATCH] Added voiceStateUpdate event listener --- src/modules/events/voiceStateUpdate.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/modules/events/voiceStateUpdate.ts diff --git a/src/modules/events/voiceStateUpdate.ts b/src/modules/events/voiceStateUpdate.ts new file mode 100644 index 0000000..e63d902 --- /dev/null +++ b/src/modules/events/voiceStateUpdate.ts @@ -0,0 +1,21 @@ +import { type VoiceState, type VoiceBasedChannel } from "discord.js" +import { type Event } from "../../types/Event" +import { spawnPlayerConnection } from "../audio/audioPlayer" + +module.exports = { + name: "voiceStateUpdate", + once: false, + rest: false, + execute: async function (oldState: VoiceState, newState: VoiceState) { + if (newState.member == null) { + console.log("member is null.") + return + } + if (newState.member.user.bot) { + console.log("user.bot is true.") + return + } + + spawnPlayerConnection(newState.channel as VoiceBasedChannel, "fortnite.mp3") + }, +} satisfies Event