JaBa/commands/Music/play.js

39 lines
998 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,
2021-12-18 18:35:03 +05:00
aliases: [ "p" ],
2021-12-10 21:39:54 +05:00
memberPermissions: [],
botPermissions: [ "SEND_MESSAGES", "EMBED_LINKS" ],
nsfw: false,
ownerOnly: false,
cooldown: 3000
2021-12-10 21:39:54 +05:00
});
}
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
2021-12-26 12:57:03 +05:00
try {
await this.client.player.play(message, args.join(" "));
} catch (e) {
message.error("music/play:ERR_OCCURRED", { error: e });
console.error(e);
}
2021-12-10 21:39:54 +05:00
}
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;