Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reputation Leaderboard #458

Open
MohamedShadd opened this issue Dec 31, 2023 · 1 comment · May be fixed by #545
Open

Reputation Leaderboard #458

MohamedShadd opened this issue Dec 31, 2023 · 1 comment · May be fixed by #545
Assignees
Labels
bug Something is verified not to work

Comments

@MohamedShadd
Copy link

The reputation leaderboard also says Deleted user

async function getRepLeaderboard(author) {
  // Create a cache key using the user ID and the type of leaderboard
  const cacheKey = `${author.id}:rep`;

  // Check if there is a cached result for this request
  if (cache.has(cacheKey)) {
    // Return the cached result if it exists
    return cache.get(cacheKey);
  }

  const lb = await getReputationLb(10);
  if (lb.length === 0) return "There are no users in the leaderboard";

  let collector = "";
  for (let i = 0; i < lb.length; i++) {
    try {
      const user = await author.client.users.fetch(lb[i].member_id);
      collector += `**#${(i + 1).toString()}** - ${escapeInlineCode(user.tag)} [${lb[i].rep}]\n`;
    } catch (ex) {
      collector += `**#${(i + 1).toString()}** - DeletedUser#0000 [${lb[i].rep}]\n`;
    }
  }

  const embed = new EmbedBuilder()
    .setAuthor({ name: "Reputation Leaderboard" })
    .setColor(EMBED_COLORS.BOT_EMBED)
    .setDescription(collector)
    .setFooter({ text: `Requested by ${author.tag}` });

  // Store the result in the cache for future requests
  cache.set(cacheKey, { embeds: [embed] });
  return { embeds: [embed] };
}
image
@MohamedShadd MohamedShadd added the bug-unverified Something isn't work label Dec 31, 2023
@saiteja-madha saiteja-madha linked a pull request Oct 29, 2024 that will close this issue
@saiteja-madha saiteja-madha added bug Something is verified not to work and removed bug-unverified Something isn't work labels Oct 29, 2024
@saiteja-madha saiteja-madha self-assigned this Oct 29, 2024
@NavIshanOp
Copy link

NavIshanOp commented Nov 3, 2024

Hey check this once :- #552

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is verified not to work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants