I want to control my Discord bot only from one voice channel, but you can just disconnect him from any voice channel. I want to make him disconnect only if you are with him in voice channel. Here is my code:
const { Command } = require('discord.js-commando');
module.exports = class LeaveCommand extends Command {
constructor(client) {
super(client, {
name: 'leave',
aliases: ['l'],
group: 'music',
memberName: 'leave',
description: 'Ies din voice channel :(.',
guildOnly: true,
});
}
run(message) {
var voiceChannel = message.member.voice.channel;
if (!voiceChannel) {
message.reply('Intra pe un voice channel si incearca din nou');
return;
}
const connection = this.client.voice.connections.get(message.guild.id);
if (!connection) return message.reply('Nu sunt intr-un voice channel.');
connection.channel.leave();
return message.reply(`Am iesit din voice channel-ul - "**__${connection.channel.name}__**"`);
}
};