From 859fa3124b973de60ddfd8ddb01cb28b624c9bc2 Mon Sep 17 00:00:00 2001 From: Ayden Jahola Date: Thu, 5 Sep 2024 20:11:52 +0100 Subject: [PATCH] Leaderboard: remove avatar cause it looks weird --- commands/fun/leaderboard.js | 42 +++++++------------------------------ 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/commands/fun/leaderboard.js b/commands/fun/leaderboard.js index 5666bfb..75eb28b 100644 --- a/commands/fun/leaderboard.js +++ b/commands/fun/leaderboard.js @@ -15,36 +15,23 @@ module.exports = { .sort({ correctAnswers: -1 }) .limit(10); - // Fetch display names and avatars for each leaderboard entry + // Fetch display names for each leaderboard entry const leaderboardEntries = await Promise.all( scores.map(async (entry, index) => { try { const member = await guild.members.fetch(entry.userId); const displayName = member ? member.displayName : entry.username; // Fallback if member not found - const avatarUrl = member.user.displayAvatarURL({ - dynamic: true, - size: 32, - }); // Get avatar URL - - return { - position: index + 1, - name: displayName, - correctAnswers: entry.correctAnswers, - gamesPlayed: entry.gamesPlayed, - avatarUrl: avatarUrl, - }; + return `${index + 1}. ${displayName}: ${ + entry.correctAnswers + } correct answers in ${entry.gamesPlayed} games`; } catch (error) { console.error( `Error fetching member for userId: ${entry.userId}`, error ); - return { - position: index + 1, - name: entry.username, - correctAnswers: entry.correctAnswers, - gamesPlayed: entry.gamesPlayed, - avatarUrl: null, // No avatar in case of error - }; + return `${index + 1}. ${entry.username}: ${ + entry.correctAnswers + } correct answers in ${entry.gamesPlayed} games`; } }) ); @@ -52,22 +39,9 @@ module.exports = { const leaderboardEmbed = new EmbedBuilder() .setColor("#0099ff") .setTitle("Trivia Leaderboard") + .setDescription(leaderboardEntries.join("\n")) .setTimestamp(); - // Add each leaderboard entry with avatar as a thumbnail - leaderboardEntries.forEach((entry) => { - const fieldValue = `${entry.correctAnswers} correct answers in ${entry.gamesPlayed} games`; - - leaderboardEmbed.addFields({ - name: `${entry.position}. ${entry.name}`, - value: fieldValue, - inline: false, - }); - - // Use the avatar URL as a thumbnail for each user entry - leaderboardEmbed.setThumbnail(entry.avatarUrl || null); - }); - if (guild.iconURL()) { leaderboardEmbed.setFooter({ text: guild.name,