Новая команда loop

This commit is contained in:
JonnyBro 2021-12-19 16:36:46 +05:00
parent 155df66ddf
commit 702d1617e0
6 changed files with 61 additions and 7 deletions

View file

@ -19,7 +19,6 @@ class Back extends Command {
async run (message, args, data) { async run (message, args, data) {
const queue = this.client.player.getQueue(message); const queue = this.client.player.getQueue(message);
const voice = message.member.voice.channel; const voice = message.member.voice.channel;
if (!voice) return message.error("music/play:NO_VOICE_CHANNEL"); if (!voice) return message.error("music/play:NO_VOICE_CHANNEL");
@ -39,7 +38,7 @@ class Back extends Command {
if (members.size > 1) { if (members.size > 1) {
m.react("👍"); m.react("👍");
const mustVote = Math.floor(members.size/2+1); const mustVote = Math.floor(members.size / 2);
embed.setDescription(message.translate("music/back:VOTE_CONTENT", { songName: queue.tracks[0].name, voteCount: 0, requiredCount: mustVote })); embed.setDescription(message.translate("music/back:VOTE_CONTENT", { songName: queue.tracks[0].name, voteCount: 0, requiredCount: mustVote }));
m.edit(embed); m.edit(embed);

View file

@ -20,8 +20,8 @@ class Filters extends Command {
async run (message, args, data) { async run (message, args, data) {
const queue = this.client.player.getQueue(message); const queue = this.client.player.getQueue(message);
const voice = message.member.voice.channel; const voice = message.member.voice.channel;
if (!voice) return message.error("music/play:NO_VOICE_CHANNEL"); if (!voice) return message.error("music/play:NO_VOICE_CHANNEL");
if (!queue) return message.error("music/play:NOT_PLAYING"); if (!queue) return message.error("music/play:NOT_PLAYING");

47
commands/Music/loop.js Normal file
View file

@ -0,0 +1,47 @@
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);
if (!args[0]) return message.error("music/loop:NO_ARG");
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) {
client.player.setLoopMode(message, true);
message.success("music:/loop:QUEUE", { loop: "включён" });
} else {
client.player.setLoopMode(message, false);
message.success("music:/loop:QUEUE", { loop: "отключён" });
};
} else if (args[0].toLowerCase() === "song") {
if (!queue.repeatMode) {
client.player.setRepeatMode(message, true);
message.success("music:/loop:QUEUE", { loop: "включён" });
} else if (args[1].toLowerCase() == "off") {
client.player.setRepeatMode(message, false);
message.success("music:/loop:QUEUE", { loop: "отключён" });
};
};
}
};
module.exports = Loop;

View file

@ -19,8 +19,8 @@ class Skip extends Command {
async run (message, args, data) { async run (message, args, data) {
const queue = this.client.player.getQueue(message); const queue = this.client.player.getQueue(message);
const voice = message.member.voice.channel; const voice = message.member.voice.channel;
if (!voice) return message.error("music/play:NO_VOICE_CHANNEL"); if (!voice) return message.error("music/play:NO_VOICE_CHANNEL");
if (!queue) return message.error("music/play:NOT_PLAYING"); if (!queue) return message.error("music/play:NOT_PLAYING");
if (!queue.tracks[0]) return message.error("music/skip:NO_NEXT_SONG"); if (!queue.tracks[0]) return message.error("music/skip:NO_NEXT_SONG");
@ -38,7 +38,7 @@ class Skip extends Command {
if (members.size > 1) { if (members.size > 1) {
m.react("👍"); m.react("👍");
const mustVote = Math.floor(members.size/2+1); const mustVote = Math.floor(members.size / 2);
embed.setDescription(message.translate("music/skip:VOTE_CONTENT", { songName: queue.tracks[0].name, voteCount: 0, requiredCount: mustVote })); embed.setDescription(message.translate("music/skip:VOTE_CONTENT", { songName: queue.tracks[0].name, voteCount: 0, requiredCount: mustVote }));
m.edit(embed); m.edit(embed);

View file

@ -19,8 +19,8 @@ class Stop extends Command {
async run (message, args, data) { async run (message, args, data) {
const queue = await this.client.player.getQueue(message); const queue = await this.client.player.getQueue(message);
const voice = message.member.voice.channel; const voice = message.member.voice.channel;
if (!voice) return message.error("music/play:NO_VOICE_CHANNEL"); if (!voice) return message.error("music/play:NO_VOICE_CHANNEL");
if (!queue) return message.error("music/play:NOT_PLAYING"); if (!queue) return message.error("music/play:NOT_PLAYING");
@ -36,7 +36,7 @@ class Stop extends Command {
if (members.size > 1) { if (members.size > 1) {
m.react("👍"); m.react("👍");
const mustVote = Math.floor(members.size/2+1); const mustVote = Math.floor(members.size / 2);
embed.setDescription(message.translate("music/stop:VOTE_CONTENT", { voteCount: 0, requiredCount: mustVote })); embed.setDescription(message.translate("music/stop:VOTE_CONTENT", { voteCount: 0, requiredCount: mustVote }));
m.edit(embed); m.edit(embed);

View file

@ -0,0 +1,8 @@
{
"DESCRIPTION": "Включить или отключить повтор очереди/одного трека!",
"USAGE": "{{prefix}}loop [queue/song]",
"EXAMPLES": "{{prefix}}loop queue\n{{prefix}}loop song",
"NO_ARG": "Выберите: `queue` или `song`!",
"QUEUE": "Повтор очереди **{{loop}}**!",
"SONG": "Повтор очереди **{{loop}}**!"
}