JaBa/commands/Music/play.js

41 lines
1 KiB
JavaScript
Raw Normal View History

const Command = require("../../base/Command.js"),
{ Permissions } = require("discord.js");
2022-01-04 02:18:28 +05:00
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(Permissions.FLAGS.CONNECT) || !perms.has(Permissions.FLAGS.SPEAK)) return message.error("music/play:VOICE_CHANNEL_CONNECT");
2022-01-04 02:18:28 +05:00
try {
this.client.player.play(message, args.join(" "));
} catch (e) {
message.error("music/play:ERR_OCCURRED", {
error: e
});
console.error(e);
}
}
2022-01-13 00:26:23 +05:00
}
2022-01-04 02:18:28 +05:00
module.exports = Play;