feat: add empty vc listener
This commit is contained in:
@@ -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<void> {
|
||||
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;
|
||||
Reference in New Issue
Block a user