Leave on alone

This commit is contained in:
Myx
2023-06-29 04:00:50 +02:00
parent e6f07d9713
commit b19e6fb95c
2 changed files with 17 additions and 2 deletions

View File

@@ -3,7 +3,10 @@
"editor.codeActionsOnSave": { "editor.codeActionsOnSave": {
"source.fixAll": true "source.fixAll": true
}, },
"eslint.validate": ["javascript"] "eslint.validate": [
"javascript"
],
"files.eol": "\n"
// "editor.formatOnSave": true, // "editor.formatOnSave": true,
// "eslint.format.enable": true // "eslint.format.enable": true

View File

@@ -1,5 +1,6 @@
const { Client, GatewayIntentBits } = require('discord.js'); const { Client, GatewayIntentBits } = require('discord.js');
const process = require('dotenv').config(); const process = require('dotenv').config();
const { getVoiceConnection } = require('@discordjs/voice');
const { registerCommands } = require('./utils/registerCommands'); const { registerCommands } = require('./utils/registerCommands');
const { playCommand } = require('./commands/play'); const { playCommand } = require('./commands/play');
const { queueCommand } = require('./commands/queue'); const { queueCommand } = require('./commands/queue');
@@ -27,6 +28,17 @@ client.on('ready', async () => {
await registerCommands(clientId, token); await registerCommands(clientId, token);
}); });
client.on('voiceStateUpdate', (oldState) => {
const voiceChannel = oldState.channel;
if (voiceChannel && voiceChannel.members.size === 1) {
const connection = getVoiceConnection(voiceChannel.guild.id);
if (connection) {
connection.disconnect();
connection.destroy();
}
}
});
client.on('interactionCreate', async (interaction) => { client.on('interactionCreate', async (interaction) => {
if (!interaction.isCommand()) return; if (!interaction.isCommand()) return;
@@ -53,4 +65,4 @@ client.on('messageCreate', async (message) => {
} }
}); });
client.login(token); client.login(token);