JaBa/commands/Music/play.js

42 lines
1 KiB
JavaScript
Raw Normal View History

2022-01-03 23:20:33 +05:00
const Command = require("../../base/Command.js"),
{ Permissions } = require("discord.js");
2021-12-10 21:39:54 +05:00
class Play extends Command {
2021-12-26 19:29:37 +05:00
constructor(client) {
2021-12-10 21:39:54 +05:00
super(client, {
name: "play",
dirname: __dirname,
enabled: true,
guildOnly: true,
2021-12-26 19:29:37 +05:00
aliases: ["p"],
2021-12-10 21:39:54 +05:00
memberPermissions: [],
2021-12-26 19:29:37 +05:00
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
2021-12-10 21:39:54 +05:00
nsfw: false,
ownerOnly: false,
cooldown: 3000
2021-12-10 21:39:54 +05:00
});
}
2021-12-26 19:29:37 +05:00
async run(message, args) {
2021-12-10 21:39:54 +05:00
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);
2022-01-03 23:20:33 +05:00
if (!perms.has(Permissions.FLAGS.CONNECT) || !perms.has(Permissions.FLAGS.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 {
2021-12-26 17:12:03 +05:00
this.client.player.play(message, args.join(" "));
2021-12-26 12:57:03 +05:00
} catch (e) {
2021-12-26 19:29:37 +05:00
message.error("music/play:ERR_OCCURRED", {
error: e
});
2021-12-26 12:57:03 +05:00
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;