From a29283721d1d106a6589d7a51aa8ac30fddfbef7 Mon Sep 17 00:00:00 2001 From: Cynthia Foxwell Date: Wed, 4 May 2022 15:46:29 -0600 Subject: [PATCH] music.play: add --next --- src/modules/music.js | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/modules/music.js b/src/modules/music.js index 5222367..8daf39d 100644 --- a/src/modules/music.js +++ b/src/modules/music.js @@ -176,7 +176,8 @@ async function enqueue( url, type, addedBy, - suppress = false + suppress = false, + queueNext = false ) { if (!url) return; @@ -258,7 +259,7 @@ async function enqueue( } if (connection.playing) { - connection._music_queue.push({ + const queueItem = { url, type, title, @@ -266,12 +267,21 @@ async function enqueue( addedBy, stream, id: Math.random().toString(16).substring(2), - }); + }; + + if (queueNext === true) { + connection._music_queue.splice(0, 0, queueItem); + } else { + connection._music_queue.push(queueItem); + } + if (suppress === false) { textChannel.createMessage({ embeds: [ { - title: `<:ms_tick:503341995348066313> Added to queue`, + title: `<:ms_tick:503341995348066313> Added to queue ${ + queueNext === true ? "(next up)" : "" + }`, color: 0x00cc00, fields: [ { @@ -423,6 +433,12 @@ command.callback = async function (msg, line) { argStr = argStr.replace(/--offset=(\d+)/, "").trim(); } + let queueNext = false; + if (argStr.match(/--next/)) { + queueNext = true; + argStr = argStr.replace(/--next/, "").trim(); + } + let type; let playlist = false; @@ -516,7 +532,9 @@ command.callback = async function (msg, line) { msg.channel.id, argStr, type, - msg.author.id + msg.author.id, + false, + queueNext ); } } else {