Store user profile picture and name for requester

This commit is contained in:
Wizzard 2024-08-17 18:14:47 -04:00
parent 7a182a39dd
commit d1abe19c88
3 changed files with 10 additions and 9 deletions

View File

@ -19,7 +19,6 @@ module.exports = {
const currentTime = player.state?.resource?.playbackDuration || 0; const currentTime = player.state?.resource?.playbackDuration || 0;
const totalDuration = getTrackDuration(currentTrack.filePath); const totalDuration = getTrackDuration(currentTrack.filePath);
const timeLeft = msToTime(totalDuration - currentTime); const timeLeft = msToTime(totalDuration - currentTime);
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
@ -29,7 +28,7 @@ module.exports = {
.addFields( .addFields(
{ name: 'Time Left', value: timeLeft }, { name: 'Time Left', value: timeLeft },
) )
.setFooter({ text: `Requested by ${message.author.username}`, iconURL: message.author.displayAvatarURL() }) .setFooter({ text: `Requested by ${currentTrack.requester}`, iconURL: currentTrack.avatarURL })
.setTimestamp(); .setTimestamp();
message.channel.send({ embeds: [embed] }); message.channel.send({ embeds: [embed] });

View File

@ -50,7 +50,7 @@ module.exports = {
message.channel.send({ embeds: [embed] }); message.channel.send({ embeds: [embed] });
console.log('Adding to queue and attempting to play.'); console.log('Adding to queue and attempting to play.');
addToQueue(message.guild.id, tempFilePath, title, voiceChannel); addToQueue(message.guild.id, tempFilePath, title, voiceChannel, videoUrl, message.author.username, message.author.displayAvatarURL());
playNextInQueue(message.guild.id); playNextInQueue(message.guild.id);
return; return;
} else { } else {
@ -84,7 +84,7 @@ module.exports = {
message.channel.send({ embeds: [embed] }); message.channel.send({ embeds: [embed] });
console.log('Adding to queue and attempting to play.'); console.log('Adding to queue and attempting to play.');
addToQueue(message.guild.id, tempFilePath, title, voiceChannel); addToQueue(message.guild.id, tempFilePath, title, voiceChannel, videoUrl, message.author.username, message.author.displayAvatarURL());
playNextInQueue(message.guild.id); playNextInQueue(message.guild.id);
return; return;
} else if (searchQuery.includes("cdn.discordapp.com")) { } else if (searchQuery.includes("cdn.discordapp.com")) {
@ -111,7 +111,7 @@ module.exports = {
message.channel.send({ embeds: [embed] }); message.channel.send({ embeds: [embed] });
console.log('Adding to queue and attempting to play.'); console.log('Adding to queue and attempting to play.');
addToQueue(message.guild.id, tempFilePath, title, voiceChannel); addToQueue(message.guild.id, tempFilePath, title, voiceChannel, videoUrl, message.author.username, message.author.displayAvatarURL());
playNextInQueue(message.guild.id); playNextInQueue(message.guild.id);
return; return;
} else { } else {
@ -148,7 +148,7 @@ module.exports = {
message.channel.send({ embeds: [embed] }); message.channel.send({ embeds: [embed] });
console.log('Adding to queue and attempting to play.'); console.log('Adding to queue and attempting to play.');
addToQueue(message.guild.id, tempFilePath, title, voiceChannel, videoUrl); addToQueue(message.guild.id, tempFilePath, title, voiceChannel, videoUrl, message.author.username, message.author.displayAvatarURL());
playNextInQueue(message.guild.id); playNextInQueue(message.guild.id);
}); });
}); });
@ -189,7 +189,7 @@ module.exports = {
message.channel.send({ embeds: [embed] }); message.channel.send({ embeds: [embed] });
console.log('Adding to queue and attempting to play.'); console.log('Adding to queue and attempting to play.');
addToQueue(message.guild.id, tempFilePath, title, voiceChannel, videoUrl); addToQueue(message.guild.id, tempFilePath, title, voiceChannel, videoUrl, message.author.username, message.author.displayAvatarURL());
playNextInQueue(message.guild.id); playNextInQueue(message.guild.id);
}); });
}); });

View File

@ -7,11 +7,11 @@ const currentTrackMap = new Map();
const repeatMap = new Map(); const repeatMap = new Map();
const voiceChannelMap = new Map(); const voiceChannelMap = new Map();
function addToQueue(guildId, filePath, title, voiceChannel, url = null) { function addToQueue(guildId, filePath, title, voiceChannel, url, requester, avatarURL) {
if (!queueMap.has(guildId)) { if (!queueMap.has(guildId)) {
queueMap.set(guildId, []); queueMap.set(guildId, []);
} }
queueMap.get(guildId).push({ filePath, title, url }); queueMap.get(guildId).push({ filePath, title, url, requester, avatarURL });
if (voiceChannel) { if (voiceChannel) {
voiceChannelMap.set(guildId, voiceChannel); voiceChannelMap.set(guildId, voiceChannel);
@ -106,6 +106,8 @@ function playTrack(guildId, voiceChannel, track) {
audioPlayer.play(resource); audioPlayer.play(resource);
connection.subscribe(audioPlayer); connection.subscribe(audioPlayer);
currentTrackMap.set(guildId, { ...track, resource });
audioPlayer.on(AudioPlayerStatus.Idle, () => { audioPlayer.on(AudioPlayerStatus.Idle, () => {
if (!repeatMap.get(guildId)) { if (!repeatMap.get(guildId)) {
currentTrackMap.delete(guildId); currentTrackMap.delete(guildId);