From 1158d32910c49612363f35be13b1c2a94701ffc8 Mon Sep 17 00:00:00 2001 From: MatteZ02 <47610069+MatteZ02@users.noreply.github.com> Date: Wed, 29 Apr 2020 14:41:16 +0300 Subject: [PATCH] Update 3.3 --- package.json | 4 ++-- src/commands/previous.js | 18 ++++++++++++++++++ src/commands/replay.js | 16 ++++++++++++++++ src/commands/skipto.js | 4 ++-- src/events/dispatcherEvents/finish.js | 7 +++++-- src/struct/config/config.js | 4 ++-- src/struct/config/emojis.js | 3 ++- src/struct/config/messages.js | 2 ++ src/struct/funcs/handleVideo.js | 1 + src/struct/funcs/play.js | 6 ++++-- 10 files changed, 54 insertions(+), 11 deletions(-) create mode 100644 src/commands/previous.js create mode 100644 src/commands/replay.js diff --git a/package.json b/package.json index 129c4884..450ccde6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "musix", - "version": "3.2.2", + "version": "3.3.0", "description": "V3 for Musix the discord music bot", "main": "./index.js", "scripts": { @@ -45,4 +45,4 @@ "ytdl-core": "^2.1.0", "zlib-sync": "^0.1.6" } -} +} \ No newline at end of file diff --git a/src/commands/previous.js b/src/commands/previous.js new file mode 100644 index 00000000..e275e676 --- /dev/null +++ b/src/commands/previous.js @@ -0,0 +1,18 @@ +module.exports = { + name: 'previous', + alias: 'prev', + usage: '', + description: 'Play the previous song.', + onlyDev: false, + permission: 'MANAGE_MESSAGES', + category: 'music', + async execute(msg, args, client, Discord, command) { + const queue = client.queue.get(msg.guild.id) + if (client.funcs.check(client, msg, command)) { + if (queue.prevSongs.length < 1) return msg.channel.send(client.messages.noPreviousSongs); + queue.endReason = "previous"; + queue.connection.dispatcher.end() + msg.channel.send(client.messages.previousSong) + } + } +}; \ No newline at end of file diff --git a/src/commands/replay.js b/src/commands/replay.js new file mode 100644 index 00000000..2969874f --- /dev/null +++ b/src/commands/replay.js @@ -0,0 +1,16 @@ +module.exports = { + name: 'replay', + alias: 'none', + usage: '', + description: 'Replay the currently playing song.', + onlyDev: false, + permission: 'MANAGE_MESSAGES', + category: 'music', + async execute(msg, args, client, Discord, command) { + const queue = client.queue.get(msg.guild.id); + if (client.funcs.check(client, msg, command)) { + queue.endReason = "replay"; + queue.connection.dispatcher.end() + } + } +}; \ No newline at end of file diff --git a/src/commands/skipto.js b/src/commands/skipto.js index 8158f709..273cbf84 100644 --- a/src/commands/skipto.js +++ b/src/commands/skipto.js @@ -20,11 +20,11 @@ module.exports = { return msg.channel.send(client.messages.noSongs); if (point < 0) return msg.channel.send(client.messages.cantSkipToCurrent); for (let i = 0; i < point; i++) { - queue.songs.shift(); + queue.prevSongs.push(queue.songs.shift()); } queue.endReason = "skipto"; queue.time = 0; queue.connection.dispatcher.end(); } }, -}; +}; \ No newline at end of file diff --git a/src/events/dispatcherEvents/finish.js b/src/events/dispatcherEvents/finish.js index 0d40d4d7..daa747be 100644 --- a/src/events/dispatcherEvents/finish.js +++ b/src/events/dispatcherEvents/finish.js @@ -13,7 +13,10 @@ module.exports = async function (client, reason, guild) { queue.time = 0; queue.votes = 0; queue.voters = []; - queue.songs.shift(); + if (reason !== "replay") { + if (reason === "previous") queue.songs.unshift(queue.prevSongs.pop()) + if (reason !== "previous") queue.prevSongs.push(queue.songs.shift()); + } } client.funcs.play(guild, queue.songs[0], client, 0, true); -}; +}; \ No newline at end of file diff --git a/src/struct/config/config.js b/src/struct/config/config.js index 8bb21679..1d656c39 100644 --- a/src/struct/config/config.js +++ b/src/struct/config/config.js @@ -21,7 +21,7 @@ module.exports = { embedColor: "#b50002", invite: "https://discordapp.com/oauth2/authorize?client_id=607266889537945605&permissions=3427328&scope=bot", supportServer: "https://discord.gg/rvHuJtB", - devMode: false, + devMode: true, api: false, saveDB: true, respawn: true, @@ -37,4 +37,4 @@ module.exports = { djrole: null, startPlaying: true, bass: 1, -}; +}; \ No newline at end of file diff --git a/src/struct/config/emojis.js b/src/struct/config/emojis.js index 5c6047ba..c5bab43a 100644 --- a/src/struct/config/emojis.js +++ b/src/struct/config/emojis.js @@ -6,6 +6,7 @@ module.exports = { megaPhone: "📣 ", notes: "", pause: "<:pause:674685548610322462> ", + previous: "<:reverse:705012312142119012> ", redx: "<:redx:674263474704220182> ", repeat: "<:repeat1:674685561377914892> ", repeatSong: "<:repeatsong:674685573419761716> ", @@ -17,4 +18,4 @@ module.exports = { stop: "<:stop:674685626108477519> ", stopWatch: ":stopwatch: ", volumeHigh: "<:volumehigh:674685637626167307> ", -}; +}; \ No newline at end of file diff --git a/src/struct/config/messages.js b/src/struct/config/messages.js index 45d869c7..ae4e71c0 100644 --- a/src/struct/config/messages.js +++ b/src/struct/config/messages.js @@ -92,6 +92,7 @@ module.exports = { "I cannot speak in your voice channel, make sure I have the proper permissions!", noPermsUseExternalEmojis: emojis.redx + "I cannot use external emojis, make sure I have the proper permissions!", + noPreviousSongs: emojis.redx + "No previous songs!", noQuery: emojis.redx + "you need to use a link or search for a song!", noResults: emojis.redx + "I could not obtain any search results!", noResultsLyrics: emojis.redx + "I could not obtain any results!", @@ -124,6 +125,7 @@ module.exports = { prefixMaxLength: "The prefix must be shorter or equal to 5 letters!", prefixSet: emojis.green_check_mark + "New prefix set to:", premiumState: "Premium status: ", + previousSong: emojis.previous + "Previous", provideANumber: "Please provide a number ranging from 1-10 to select one of the search results.", provideASong: emojis.redx + "Please provide a song position in queue for me to remove!", queueDeleted: "Queue deleted!", diff --git a/src/struct/funcs/handleVideo.js b/src/struct/funcs/handleVideo.js index 1ae2c1ae..a7d0cc00 100644 --- a/src/struct/funcs/handleVideo.js +++ b/src/struct/funcs/handleVideo.js @@ -30,6 +30,7 @@ module.exports = async function ( voiceChannel: voiceChannel, connection: null, songs: [], + prevSongs: [], volume: client.global.db.guilds[msg.guild.id].defaultVolume, bass: client.global.db.guilds[msg.guild.id].bass, nigthCore: false, diff --git a/src/struct/funcs/play.js b/src/struct/funcs/play.js index 11ca55da..5ed7c6eb 100644 --- a/src/struct/funcs/play.js +++ b/src/struct/funcs/play.js @@ -1,5 +1,7 @@ module.exports = async function (guild, song, client, seek, play) { - const { Readable: ReadableStream } = require("stream"); + const { + Readable: ReadableStream + } = require("stream"); const Discord = require("discord.js"); const ytdl = require("ytdl-core"); const streamConfig = require("../config/streamConfig.js"); @@ -75,4 +77,4 @@ module.exports = async function (guild, song, client, seek, play) { queue.textChannel.send(embed); } queue.playing = true; -}; +}; \ No newline at end of file