JaBa/commands/Music/play.js

40 lines
992 B
JavaScript
Raw Normal View History

2022-01-04 02:18:28 +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: ["p"],
memberPermissions: [],
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
nsfw: false,
ownerOnly: false,
cooldown: 3000
});
}
async run(message, args) {
const voice = message.member.voice.channel;
2022-01-04 21:22:41 +05:00
const name = args.join(" ");
2022-01-04 02:18:28 +05:00
if (!voice) return message.error("music/play:NO_VOICE_CHANNEL");
2022-01-04 21:22:41 +05:00
if (!name) return message.error("music/play:MISSING_SONG_NAME");
2022-01-04 02:18:28 +05:00
// Check my permissions
const perms = voice.permissionsFor(this.client.user);
if (!perms.has("CONNECT") || !perms.has("SPEAK")) return message.error("music/play:VOICE_CHANNEL_CONNECT");
try {
this.client.player.play(message, args.join(" "));
} catch (e) {
message.error("music/play:ERR_OCCURRED", {
error: e
});
console.error(e);
}
}
};
module.exports = Play;