JaBa/commands/Music/play.js

34 lines
884 B
JavaScript
Raw Normal View History

2021-12-10 21:39:54 +05:00
const Command = require("../../base/Command.js");
class Play extends Command {
constructor (client) {
super(client, {
name: "play",
dirname: __dirname,
enabled: true,
guildOnly: true,
aliases: [],
2021-12-10 21:39:54 +05:00
memberPermissions: [],
botPermissions: [ "SEND_MESSAGES", "EMBED_LINKS" ],
nsfw: false,
ownerOnly: false,
cooldown: 5000
});
}
async run (message, args) {
const name = args.join(" ");
2021-12-11 01:11:50 +05:00
if (!name) return message.error("music/play:MISSING_SONG_NAME");
2021-12-10 21:39:54 +05:00
const voice = message.member.voice.channel;
2021-12-11 01:11:50 +05:00
if (!voice) return message.error("music/play:NO_VOICE_CHANNEL");
2021-12-10 21:39:54 +05:00
// Check my permissions
const perms = voice.permissionsFor(this.client.user);
2021-12-11 01:11:50 +05:00
if (!perms.has("CONNECT") || !perms.has("SPEAK")) return message.error("music/play:VOICE_CHANNEL_CONNECT");
2021-12-10 21:39:54 +05:00
await this.client.player.play(message, args.join(" "));
}
2021-12-11 01:11:50 +05:00
};
2021-12-10 21:39:54 +05:00
2021-12-11 01:11:50 +05:00
module.exports = Play;