music: implement queue command

This commit is contained in:
Cynthia Foxwell 2022-04-24 11:34:54 -06:00
parent 64b34c56d6
commit d033366c6c

View file

@ -596,7 +596,42 @@ command.callback = async function (msg, line) {
}; };
} }
case "queue": case "queue":
case "q": case "q": {
if (!voiceStorage.has(msg.guildID))
return "The bot is not in a voice channel";
const connection = voiceStorage.get(msg.guildID);
const queue = connection._music_queue;
if (queue.length === 0) return "Nothing else is currently queued";
const nowPlaying = connection._music_nowplaying;
const now = Date.now();
let nextTrack = now + (nowPlaying.length - (now - nowPlaying.start));
const fields = [];
for (const index in queue.slice(0, 8)) {
const item = queue[index];
fields.push({
name: item.title ? `[${item.title}](${item.url})` : item.url,
value: `${formatTime(item.length)}\nAdded by: <@${
item.addedBy
}>\n<t:${nextTrack}:R>`,
inline: true,
});
nextTrack += item.length;
}
return {
embed: {
title: "Currently Queued",
color: 0x0088cc,
fields,
footer: {
text: queue.length > 9 ? `Showing 9/${queue.length}` : "",
},
},
};
}
case "remove": case "remove":
case "qr": case "qr":
case "lock": case "lock":