From e3ad17d25e69ce27618e2ea3ea8ebbc1750bf90c Mon Sep 17 00:00:00 2001 From: neru Date: Sat, 10 Jan 2026 12:22:18 -0300 Subject: [PATCH] feat: add empty vc listener --- src/commands/voice/userListener.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/commands/voice/userListener.ts diff --git a/src/commands/voice/userListener.ts b/src/commands/voice/userListener.ts new file mode 100644 index 0000000..7ba7215 --- /dev/null +++ b/src/commands/voice/userListener.ts @@ -0,0 +1,28 @@ +import { VoiceState } from "discord.js"; +import { Command } from "../../commands"; +import { getVoiceConnection } from "@discordjs/voice"; + +const cmd: Command = { + voiceStateListener: async function (oldState: VoiceState): Promise { + const guild = oldState.guild; + if (!guild) return; + + const voiceConnection = getVoiceConnection(guild.id); + if (!voiceConnection) return; + + const me = guild.members.me; + if (!me) + return; + + if (!me.voice.channel) + return; + + if (me.voice.channel.members.size > 1) + return; + + voiceConnection.disconnect(); + voiceConnection.destroy(); + } +} + +export default cmd; \ No newline at end of file