Leave on alone
This commit is contained in:
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
@@ -3,7 +3,10 @@
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll": true
|
||||
},
|
||||
"eslint.validate": ["javascript"]
|
||||
"eslint.validate": [
|
||||
"javascript"
|
||||
],
|
||||
"files.eol": "\n"
|
||||
|
||||
// "editor.formatOnSave": true,
|
||||
// "eslint.format.enable": true
|
||||
|
||||
14
index.js
14
index.js
@@ -1,5 +1,6 @@
|
||||
const { Client, GatewayIntentBits } = require('discord.js');
|
||||
const process = require('dotenv').config();
|
||||
const { getVoiceConnection } = require('@discordjs/voice');
|
||||
const { registerCommands } = require('./utils/registerCommands');
|
||||
const { playCommand } = require('./commands/play');
|
||||
const { queueCommand } = require('./commands/queue');
|
||||
@@ -27,6 +28,17 @@ client.on('ready', async () => {
|
||||
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) => {
|
||||
if (!interaction.isCommand()) return;
|
||||
|
||||
@@ -53,4 +65,4 @@ client.on('messageCreate', async (message) => {
|
||||
}
|
||||
});
|
||||
|
||||
client.login(token);
|
||||
client.login(token);
|
||||
Reference in New Issue
Block a user