mirror of
https://github.com/kirameki-cafe/Yumi.git
synced 2026-09-13 10:49:20 +00:00
Added queue shuffle
This commit is contained in:
+3
-2
@@ -115,13 +115,14 @@
|
|||||||
},
|
},
|
||||||
"musicplayer_queue": {
|
"musicplayer_queue": {
|
||||||
"title": "Queue",
|
"title": "Queue",
|
||||||
"valid_args": "``clear``",
|
"valid_args": "``clear`` ``shuffle``",
|
||||||
"empty": "The queue is empty! (っ˘ω˘ς )",
|
"empty": "The queue is empty! (っ˘ω˘ς )",
|
||||||
"now_playing": "Now playing",
|
"now_playing": "Now playing",
|
||||||
"upcoming_song": "Upcoming song",
|
"upcoming_song": "Upcoming song",
|
||||||
"looping_current": "(Looping current)",
|
"looping_current": "(Looping current)",
|
||||||
"song_x_in_queue": "There are {{COUNT}} song in the queue!",
|
"song_x_in_queue": "There are {{COUNT}} song in the queue!",
|
||||||
"cleared": "Queue cleared~ (。•ˇ‸ˇ•。)"
|
"cleared": "Queue cleared~ (。•ˇ‸ˇ•。)",
|
||||||
|
"shuffled": "Queue shuffled"
|
||||||
},
|
},
|
||||||
"musicplayer_search": {
|
"musicplayer_search": {
|
||||||
"title": "Search",
|
"title": "Search",
|
||||||
|
|||||||
+3
-2
@@ -115,13 +115,14 @@
|
|||||||
},
|
},
|
||||||
"musicplayer_queue": {
|
"musicplayer_queue": {
|
||||||
"title": "キュー",
|
"title": "キュー",
|
||||||
"valid_args": "``clear``",
|
"valid_args": "``clear`` ``shuffle``",
|
||||||
"empty": "キューは空です! (っ˘ω˘ς )",
|
"empty": "キューは空です! (っ˘ω˘ς )",
|
||||||
"now_playing": "再生中",
|
"now_playing": "再生中",
|
||||||
"upcoming_song": "次の曲",
|
"upcoming_song": "次の曲",
|
||||||
"looping_current": "(この曲の繰り返し)",
|
"looping_current": "(この曲の繰り返し)",
|
||||||
"song_x_in_queue": "{{COUNT}}曲も並んでいますよ。",
|
"song_x_in_queue": "{{COUNT}}曲も並んでいますよ。",
|
||||||
"cleared": "キューがクリアされました (。•ˇ‸ˇ•。)"
|
"cleared": "キューがクリアされました (。•ˇ‸ˇ•。)",
|
||||||
|
"shuffled": "キューがシャッフルされました"
|
||||||
},
|
},
|
||||||
"musicplayer_search": {
|
"musicplayer_search": {
|
||||||
"title": "検索",
|
"title": "検索",
|
||||||
|
|||||||
+3
-2
@@ -115,13 +115,14 @@
|
|||||||
},
|
},
|
||||||
"musicplayer_queue": {
|
"musicplayer_queue": {
|
||||||
"title": "คิวเพลง",
|
"title": "คิวเพลง",
|
||||||
"valid_args": "``clear``",
|
"valid_args": "``clear`` ``shuffle``",
|
||||||
"empty": "ตอนนี้คิวว่างนะ (っ˘ω˘ς )",
|
"empty": "ตอนนี้คิวว่างนะ (っ˘ω˘ς )",
|
||||||
"now_playing": "กำลังเล่น",
|
"now_playing": "กำลังเล่น",
|
||||||
"upcoming_song": "เพลงต่อไป",
|
"upcoming_song": "เพลงต่อไป",
|
||||||
"looping_current": "(กำลังวนซ้ำเพลงนี้)",
|
"looping_current": "(กำลังวนซ้ำเพลงนี้)",
|
||||||
"song_x_in_queue": "ตอนนี้มี {{COUNT}} เพลงอยู่ในคิว!",
|
"song_x_in_queue": "ตอนนี้มี {{COUNT}} เพลงอยู่ในคิว!",
|
||||||
"cleared": "เคลียร์คิวเรียบร้อยละ~ (。•ˇ‸ˇ•。)"
|
"cleared": "เคลียร์คิวเรียบร้อยละ~ (。•ˇ‸ˇ•。)",
|
||||||
|
"shuffled": "สุ่มคิวเรียบร้อยละ"
|
||||||
},
|
},
|
||||||
"musicplayer_search": {
|
"musicplayer_search": {
|
||||||
"title": "ค้นหา",
|
"title": "ค้นหา",
|
||||||
|
|||||||
@@ -78,6 +78,12 @@ const EMBEDS = {
|
|||||||
user: data.getUser()
|
user: data.getUser()
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
QUEUE_SHUFFLED: (data: HybridInteractionMessage, locale: I18n) => {
|
||||||
|
return makeSuccessEmbed({
|
||||||
|
title: locale.__('musicplayer_queue.shuffled'),
|
||||||
|
user: data.getUser()
|
||||||
|
});
|
||||||
|
},
|
||||||
NO_MUSIC_PLAYING: (data: HybridInteractionMessage, locale: I18n) => {
|
NO_MUSIC_PLAYING: (data: HybridInteractionMessage, locale: I18n) => {
|
||||||
return makeErrorEmbed({
|
return makeErrorEmbed({
|
||||||
title: locale.__('musicplayer.no_music_playing'),
|
title: locale.__('musicplayer.no_music_playing'),
|
||||||
@@ -124,10 +130,13 @@ export default class QueueCommand extends DiscordModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!query) return;
|
if (!query) return;
|
||||||
if (query.toLowerCase() !== 'clear') return;
|
switch (query.toLowerCase()) {
|
||||||
|
case 'clear':
|
||||||
instance.clearQueue();
|
instance.clearQueue();
|
||||||
|
|
||||||
return await sendHybridInteractionMessageResponse(data, { embeds: [EMBEDS.QUEUE_CLEARED(data, locale)] });
|
return await sendHybridInteractionMessageResponse(data, { embeds: [EMBEDS.QUEUE_CLEARED(data, locale)] });
|
||||||
|
case 'shuffle':
|
||||||
|
instance.shuffleQueue();
|
||||||
|
return await sendHybridInteractionMessageResponse(data, { embeds: [EMBEDS.QUEUE_SHUFFLED(data, locale)] });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -343,6 +343,24 @@ export class DiscordMusicPlayerInstance {
|
|||||||
this.queue.track = [this.queue.track[0]];
|
this.queue.track = [this.queue.track[0]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public shuffleQueue() {
|
||||||
|
if (!this.voiceConnection) throw new Error('No voice connection');
|
||||||
|
|
||||||
|
const shuffleFixedFirst = (queue: ValidTracks[]) => {
|
||||||
|
if(queue.length <= 2) return queue;
|
||||||
|
|
||||||
|
const fixedFirst = queue.shift();
|
||||||
|
if(!fixedFirst) return queue;
|
||||||
|
|
||||||
|
queue.sort(() => Math.random() - 0.5);
|
||||||
|
queue.unshift(fixedFirst);
|
||||||
|
return queue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!this.queue.track || this.queue.track.length === 0) return;
|
||||||
|
this.queue.track = shuffleFixedFirst(this.queue.track);
|
||||||
|
}
|
||||||
|
|
||||||
public setLoopMode(mode: DiscordMusicPlayerLoopMode) {
|
public setLoopMode(mode: DiscordMusicPlayerLoopMode) {
|
||||||
this.loopMode = mode;
|
this.loopMode = mode;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user