From 702d1617e0e7dbb5df829e338348634f59020812 Mon Sep 17 00:00:00 2001 From: JonnyBro Date: Sun, 19 Dec 2021 16:36:46 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=BE=D0=B2=D0=B0=D1=8F=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BC=D0=B0=D0=BD=D0=B4=D0=B0=20loop?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/Music/back.js | 3 +-- commands/Music/filters.js | 2 +- commands/Music/loop.js | 47 +++++++++++++++++++++++++++++++++ commands/Music/skip.js | 4 +-- commands/Music/stop.js | 4 +-- languages/ru-RU/music/loop.json | 8 ++++++ 6 files changed, 61 insertions(+), 7 deletions(-) create mode 100644 commands/Music/loop.js create mode 100644 languages/ru-RU/music/loop.json diff --git a/commands/Music/back.js b/commands/Music/back.js index 0f61f9b8..332e9c1f 100644 --- a/commands/Music/back.js +++ b/commands/Music/back.js @@ -19,7 +19,6 @@ class Back extends Command { async run (message, args, data) { const queue = this.client.player.getQueue(message); - const voice = message.member.voice.channel; if (!voice) return message.error("music/play:NO_VOICE_CHANNEL"); @@ -39,7 +38,7 @@ class Back extends Command { if (members.size > 1) { 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 })); m.edit(embed); diff --git a/commands/Music/filters.js b/commands/Music/filters.js index 3b6aa440..3a95dc6b 100644 --- a/commands/Music/filters.js +++ b/commands/Music/filters.js @@ -20,8 +20,8 @@ class Filters extends Command { async run (message, args, data) { const queue = this.client.player.getQueue(message); - const voice = message.member.voice.channel; + if (!voice) return message.error("music/play:NO_VOICE_CHANNEL"); if (!queue) return message.error("music/play:NOT_PLAYING"); diff --git a/commands/Music/loop.js b/commands/Music/loop.js new file mode 100644 index 00000000..fdbc8bc8 --- /dev/null +++ b/commands/Music/loop.js @@ -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; \ No newline at end of file diff --git a/commands/Music/skip.js b/commands/Music/skip.js index 3ae0d90e..d9a74159 100644 --- a/commands/Music/skip.js +++ b/commands/Music/skip.js @@ -19,8 +19,8 @@ class Skip extends Command { async run (message, args, data) { const queue = this.client.player.getQueue(message); - const voice = message.member.voice.channel; + if (!voice) return message.error("music/play:NO_VOICE_CHANNEL"); if (!queue) return message.error("music/play:NOT_PLAYING"); if (!queue.tracks[0]) return message.error("music/skip:NO_NEXT_SONG"); @@ -38,7 +38,7 @@ class Skip extends Command { if (members.size > 1) { 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 })); m.edit(embed); diff --git a/commands/Music/stop.js b/commands/Music/stop.js index d950b725..34bf98ad 100644 --- a/commands/Music/stop.js +++ b/commands/Music/stop.js @@ -19,8 +19,8 @@ class Stop extends Command { async run (message, args, data) { const queue = await this.client.player.getQueue(message); - const voice = message.member.voice.channel; + if (!voice) return message.error("music/play:NO_VOICE_CHANNEL"); if (!queue) return message.error("music/play:NOT_PLAYING"); @@ -36,7 +36,7 @@ class Stop extends Command { if (members.size > 1) { 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 })); m.edit(embed); diff --git a/languages/ru-RU/music/loop.json b/languages/ru-RU/music/loop.json new file mode 100644 index 00000000..eb1ef9f1 --- /dev/null +++ b/languages/ru-RU/music/loop.json @@ -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}}**!" +} \ No newline at end of file