aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKoopa <[email protected]>2022-01-17 14:17:31 -0500
committerGitHub <[email protected]>2022-01-17 13:17:31 -0600
commit7090ed2a521d32d094ba4e980f8d7b09f85f34e9 (patch)
tree074e4e703be19d73767e0f93e5372c86b0dfad53 /src
parentc22722ea0e954003ed91133fca31cc7ceee2d519 (diff)
downloadmuse-7090ed2a521d32d094ba4e980f8d7b09f85f34e9.tar.xz
muse-7090ed2a521d32d094ba4e980f8d7b09f85f34e9.zip
Add option to shuffle newly added playlist (#473)
Co-authored-by: Max Isom <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/commands/play.ts10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/commands/play.ts b/src/commands/play.ts
index 710bb06..784885e 100644
--- a/src/commands/play.ts
+++ b/src/commands/play.ts
@@ -1,6 +1,7 @@
import {TextChannel, Message} from 'discord.js';
import {URL} from 'url';
import {Except} from 'type-fest';
+import shuffle from 'array-shuffle';
import {TYPES} from '../types.js';
import {inject, injectable} from 'inversify';
import {QueuedSong, STATUS} from '../services/player.js';
@@ -26,6 +27,8 @@ export default class implements Command {
['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'],
+ ['play https://www.youtube.com/watch?list=PLi9drqWffJ9FWBo7ZVOiaVy0UQQEm4IbP shuffle', 'adds the shuffled playlist to the queue'],
+ ['play https://www.youtube.com/watch?list=PLi9drqWffJ9FWBo7ZVOiaVy0UQQEm4IbP s', 'adds the shuffled playlist to the queue'],
];
public requiresVC = true;
@@ -78,8 +81,9 @@ export default class implements Command {
}
const addToFrontOfQueue = args[args.length - 1] === 'i' || args[args.length - 1] === 'immediate';
+ const shuffleAdditions = args[args.length - 1] === 's' || args[args.length - 1] === 'shuffle';
- const newSongs: Array<Except<QueuedSong, 'addedInChannelId'>> = [];
+ let newSongs: Array<Except<QueuedSong, 'addedInChannelId'>> = [];
let extraMsg = '';
// Test if it's a complete URL
@@ -150,6 +154,10 @@ export default class implements Command {
return;
}
+ if (shuffleAdditions) {
+ newSongs = shuffle(newSongs);
+ }
+
newSongs.forEach(song => {
player.add({...song, addedInChannelId: msg.channel.id}, {immediate: addToFrontOfQueue});
});