New voice system

This commit is contained in:
Dragon Fire
2024-03-20 16:20:34 -04:00
parent 60ef3c77db
commit 355304797d
7 changed files with 75 additions and 41 deletions
+4 -5
View File
@@ -1,5 +1,4 @@
const Command = require('../../framework/Command');
const { getVoiceConnection } = require('@discordjs/voice');
module.exports = class LeaveCommand extends Command {
constructor(client) {
@@ -15,13 +14,13 @@ module.exports = class LeaveCommand extends Command {
}
run(msg) {
const connection = getVoiceConnection(msg.guild.id);
const connection = this.client.dispatchers.get(msg.guild.id);
if (!connection) return msg.reply('I am not in a voice channel.');
if (this.client.dispatchers.has(msg.guild.id)) {
if (!connection.canPlay) {
const usage = this.client.registry.commands.get('stop').usage();
return msg.reply(`I am currently playing audio in this server. Please use ${usage} first.`);
}
connection.destroy();
return msg.reply('No more words out of me...');
connection.leave();
return msg.reply(`Left **${connection.channel.name}**...`);
}
};