Add util-voice group

This commit is contained in:
Dragon Fire
2021-02-12 18:16:31 -05:00
parent 7b389ce679
commit f8b178bd9d
4 changed files with 4 additions and 3 deletions
-30
View File
@@ -1,30 +0,0 @@
const Command = require('../../structures/Command');
module.exports = class JoinCommand extends Command {
constructor(client) {
super(client, {
name: 'join',
aliases: ['join-voice-channel', 'join-vc', 'join-voice', 'join-channel'],
group: 'util-public',
memberName: 'join',
description: 'Joins your voice channel.',
guildOnly: true,
guarded: true,
userPermissions: ['CONNECT']
});
}
async run(msg) {
const voiceChannel = msg.member.voice.channel;
if (!voiceChannel) return msg.reply('Please enter a voice channel first.');
if (!voiceChannel.permissionsFor(this.client.user).has(['CONNECT', 'SPEAK', 'VIEW_CHANNEL'])) {
return msg.reply('I\'m missing the "Connect", "Speak", or "View Channel" permission for this channel.');
}
if (!voiceChannel.joinable) return msg.reply('Your voice channel is not joinable.');
if (this.client.voice.connections.has(voiceChannel.guild.id)) {
return msg.reply('I am already in a voice channel.');
}
await voiceChannel.join();
return msg.reply(`Joined **${voiceChannel.name}**!`);
}
};
-29
View File
@@ -1,29 +0,0 @@
const Command = require('../../structures/Command');
module.exports = class LeaveCommand extends Command {
constructor(client) {
super(client, {
name: 'leave',
aliases: ['leave-voice-channel', 'leave-vc', 'leave-voice', 'leave-channel'],
group: 'util-public',
memberName: 'leave',
description: 'Leaves the current voice channel.',
guildOnly: true,
guarded: true
});
}
run(msg) {
const connection = this.client.voice.connections.get(msg.guild.id);
if (!connection) return msg.reply('I am not in a voice channel.');
if (!msg.channel.permissionsFor(msg.author).has('MOVE_MEMBERS') && connection.channel.members.size > 2) {
return msg.reply('You need the "Move members" permission to remove me from this voice channel.');
}
if (this.client.dispatchers.has(msg.guild.id)) {
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.channel.leave();
return msg.reply(`Left **${connection.channel.name}**...`);
}
};
-28
View File
@@ -1,28 +0,0 @@
const Command = require('../../structures/Command');
module.exports = class StopCommand extends Command {
constructor(client) {
super(client, {
name: 'stop',
aliases: ['stop-voice-channel', 'stop-vc', 'stop-voice', 'stop-play', 'stop-playing'],
group: 'util-public',
memberName: 'stop',
description: 'Stops the current audio playing.',
guildOnly: true,
guarded: true
});
}
run(msg) {
const connection = this.client.voice.connections.get(msg.guild.id);
if (!connection) return msg.reply('I am not in a voice channel.');
if (!msg.channel.permissionsFor(msg.author).has('MOVE_MEMBERS') && connection.channel.members.size > 2) {
return msg.reply('You need the "Move members" permission to stop playing audio.');
}
if (!this.client.dispatchers.has(msg.guild.id)) {
return msg.reply(`I am not currently playing audio in this server.`);
}
this.client.dispatchers.get(msg.guild.id).end();
return msg.reply('Stopped playing.');
}
};