diff options
| author | Max Isom <[email protected]> | 2021-04-30 12:05:45 -0400 |
|---|---|---|
| committer | Max Isom <[email protected]> | 2021-04-30 12:05:45 -0400 |
| commit | d61107aedd5a7108cd3dc1eb6a542ed38f551e00 (patch) | |
| tree | 88e626265ebababf57a452e95dfda430803d5d81 /src/commands | |
| parent | 91da6d0064decca8fe5f7537aeeb9bc77ce7934c (diff) | |
| download | muse-d61107aedd5a7108cd3dc1eb6a542ed38f551e00.tar.xz muse-d61107aedd5a7108cd3dc1eb6a542ed38f551e00.zip | |
Add play immediate feature
Diffstat (limited to 'src/commands')
| -rw-r--r-- | src/commands/play.ts | 12 | ||||
| -rw-r--r-- | src/commands/queue.ts | 6 |
2 files changed, 13 insertions, 5 deletions
diff --git a/src/commands/play.ts b/src/commands/play.ts index d4f8ba2..c301fe9 100644 --- a/src/commands/play.ts +++ b/src/commands/play.ts @@ -21,7 +21,9 @@ export default class implements Command { ['play https://www.youtube.com/watch?list=PLi9drqWffJ9FWBo7ZVOiaVy0UQQEm4IbP', 'adds the playlist to the queue'], ['play https://open.spotify.com/track/3ebXMykcMXOcLeJ9xZ17XH?si=tioqSuyMRBWxhThhAW51Ig', 'plays a song from Spotify'], ['play https://open.spotify.com/album/5dv1oLETxdsYOkS2Sic00z?si=bDa7PaloRx6bMIfKdnvYQw', 'adds all songs from album to the queue'], - ['play https://open.spotify.com/playlist/37i9dQZF1DX94qaYRnkufr?si=r2fOVL_QQjGxFM5MWb84Xw', 'adds all songs from playlist to the queue'] + ['play https://open.spotify.com/playlist/37i9dQZF1DX94qaYRnkufr?si=r2fOVL_QQjGxFM5MWb84Xw', 'adds all songs from playlist to the queue'], + ['play cool music immediate', 'adds the first search result for "cool music" to the front of the queue'], + ['play cool music i', 'adds the first search result for "cool music" to the front of the queue'] ]; public requiresVC = true; @@ -64,6 +66,8 @@ export default class implements Command { return; } + const addToFrontOfQueue = args[args.length - 1] === 'i' || args[args.length - 1] === 'immediate'; + const newSongs: QueuedSong[] = []; let extraMsg = ''; @@ -112,7 +116,7 @@ export default class implements Command { } } catch (_: unknown) { // Not a URL, must search YouTube - const query = args.join(' '); + const query = addToFrontOfQueue ? args.slice(0, args.length - 1).join(' ') : args.join(' '); const song = await this.getSongs.youtubeVideoSearch(query); @@ -129,7 +133,7 @@ export default class implements Command { return; } - newSongs.forEach(song => player.add(song)); + newSongs.forEach(song => player.add(song, {immediate: addToFrontOfQueue})); const firstSong = newSongs[0]; @@ -138,7 +142,7 @@ export default class implements Command { } if (newSongs.length === 1) { - await res.stop(`u betcha, **${firstSong.title}** added to the queue${extraMsg}`); + await res.stop(`u betcha, **${firstSong.title}** added to the${addToFrontOfQueue ? ' front of the' : ''} queue${extraMsg}`); } else { await res.stop(`u betcha, **${firstSong.title}** and ${newSongs.length - 1} other songs were added to the queue${extraMsg}`); } diff --git a/src/commands/queue.ts b/src/commands/queue.ts index 8bfe155..0abc63c 100644 --- a/src/commands/queue.ts +++ b/src/commands/queue.ts @@ -35,7 +35,9 @@ export default class implements Command { const queueSize = player.queueSize(); const queuePage = args[0] ? parseInt(args[0], 10) : 1; - if (queuePage * PAGE_SIZE > queueSize && queuePage > Math.ceil((queueSize + 1) / PAGE_SIZE)) { + const maxQueuePage = Math.ceil((queueSize + 1) / PAGE_SIZE); + + if (queuePage > maxQueuePage) { await msg.channel.send(errorMsg('the queue isn\'t that big')); return; } @@ -70,6 +72,8 @@ export default class implements Command { embed.addField(`${(i + 1 + queuePageBegin).toString()}/${queueSize.toString()}`, song.title, false); }); + embed.addField('Page', `${queuePage} out of ${maxQueuePage}`, false); + await msg.channel.send(embed); } else { await msg.channel.send('queue empty'); |
