JaBa/commands/Music/loop.js

51 lines
1.5 KiB
JavaScript
Raw Normal View History

2021-12-19 16:36:46 +05:00
const Command = require("../../base/Command.js");
class Loop extends Command {
constructor (client) {
super(client, {
name: "loop",
dirname: __dirname,
enabled: true,
guildOnly: true,
aliases: [],
memberPermissions: [],
botPermissions: [ "SEND_MESSAGES" ],
nsfw: false,
ownerOnly: false,
cooldown: 1000
});
}
async run (message, args) {
const voice = message.member.voice.channel;
const queue = this.client.player.getQueue(message);
2021-12-19 20:38:49 +05:00
if (!args[0] || !["queue", "song"].includes(args[0])) return message.error("music/loop:NO_ARG");
2021-12-19 16:36:46 +05:00
if (!voice) return message.error("music/play:NO_VOICE_CHANNEL");
if (!queue) return message.error("music/play:NOT_PLAYING");
if (args[0].toLowerCase() === "queue") {
if (!queue.loopMode) {
2021-12-19 16:57:00 +05:00
if (queue.repeatMode) this.client.player.setRepeatMode(message, false);
2021-12-19 20:38:49 +05:00
2021-12-19 16:52:00 +05:00
this.client.player.setLoopMode(message, true);
2021-12-19 16:53:05 +05:00
message.success("music/loop:QUEUE", { loop: "включён" });
2021-12-19 16:36:46 +05:00
} else {
2021-12-19 16:52:00 +05:00
this.client.player.setLoopMode(message, false);
2021-12-19 16:53:05 +05:00
message.success("music/loop:QUEUE", { loop: "отключён" });
2021-12-19 16:36:46 +05:00
};
} else if (args[0].toLowerCase() === "song") {
if (!queue.repeatMode) {
2021-12-19 16:57:00 +05:00
if (queue.loopMode) this.client.player.setLoopMode(message, false);
2021-12-19 16:52:00 +05:00
this.client.player.setRepeatMode(message, true);
2021-12-19 16:53:05 +05:00
message.success("music/loop:QUEUE", { loop: "включён" });
2021-12-19 16:54:28 +05:00
} else {
2021-12-19 16:52:00 +05:00
this.client.player.setRepeatMode(message, false);
2021-12-19 16:53:05 +05:00
message.success("music/loop:QUEUE", { loop: "отключён" });
2021-12-19 16:36:46 +05:00
};
};
}
};
module.exports = Loop;