Skip to content

Feature/leaderboard command#1465

Open
barsh404error wants to merge 4 commits into
Together-Java:developfrom
barsh404error:feature/leaderboard-command
Open

Feature/leaderboard command#1465
barsh404error wants to merge 4 commits into
Together-Java:developfrom
barsh404error:feature/leaderboard-command

Conversation

@barsh404error
Copy link
Copy Markdown
Member

@barsh404error barsh404error commented Apr 25, 2026

What

Adds a /leaderboard command that displays the all-time top helpers. It reads the hall-of-fame channel history, finds messages that mention top helpers, counts how many times each user was awarded, and shows the top 10 ranked with medals.

How

Reads the hall-of-fame channel history, filters messages containing "top helper", extracts mentioned users via getMentions(), counts wins per user and shows the top 10 in an embed.

Screenshot From 2026-05-26 21-56-39

Edge cases

  • Channel not found: yes, returns "Could not find the hall of fame channel."
  • No messages in channel: yes, sorted.isEmpty() catches it, then returns "No top helper data found."
  • Messages exist but none contain "top helper": yes, the same sorted.isEmpty() check covers it.
  • Multiple users in one message: yes, the getMentions().getUsers() loop handles multiple mentions per message.
Screenshot From 2026-05-27 15-32-30 Screenshot From 2026-05-27 15-32-54 Screenshot From 2026-05-27 15-42-14

NOTE: Channel not found and Messages exist but none contain "top helper" returns the same output "No top helper data found."

@barsh404error barsh404error requested a review from a team as a code owner April 25, 2026 09:18
@barsh404error barsh404error force-pushed the feature/leaderboard-command branch from 8a9840f to ff6632d Compare April 25, 2026 09:23
@barsh404error barsh404error self-assigned this Apr 25, 2026
@barsh404error barsh404error force-pushed the feature/leaderboard-command branch from ff6632d to 9bb9883 Compare April 25, 2026 09:36

event.deferReply().queue();

Pattern channelPattern =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this to the constructor. We don't need to run this everytime the slash command is invoked.

private static void countWinsInto(List<Message> messages, Map<Long, Integer> wins) {
for (Message message : messages) {
String content = message.getContentRaw();
if (!content.toLowerCase().contains("top helper")) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exclude the leaderboard it self so add 🏆 Top Helpers — Hall of Fame as part of your check.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make it a constant is it's not duplicated either, please.

if (hallOfFame == null) {
event.getHook()
.editOriginal(
"Could not find channel matching '%s'.".formatted(channelPattern.pattern()))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

injection. u will get discord markdown formatting on typical patterns here. at least put a code fence `

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants