Skip to content

Commit

Permalink
Added a little more detail for week leaderboard to be able to differe…
Browse files Browse the repository at this point in the history
…ntiate weeks (#28)
  • Loading branch information
SaltyQuetzals authored Jun 10, 2024
1 parent b6225df commit 65d1b9a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/commands/subcommands/leaderboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ const calculateLeaderboardForWeek = async (
weekNumber: number,
interaction: ChatInputCommandInteraction<CacheType>,
) => {
const week = await prisma.week.findFirst({
where: {
number: weekNumber,
seasonNumber,
},
});

const entries = await prisma.entry.findMany({
select: {
userId: true,
Expand All @@ -64,7 +71,15 @@ const calculateLeaderboardForWeek = async (
},
});

const response = [`# RMFP Season ${seasonNumber} Week ${weekNumber}`];
if (week === null) {
await interaction.reply({
content: `Hm... I can't find any entries for S${seasonNumber}W${weekNumber}`,
ephemeral: true,
});
return;
}

const response = [`# RMFP Season ${seasonNumber} Week ${weekNumber}`, `**Theme**: ${week.theme}`];

for (const [idx, entry] of entries.entries()) {
response.push(`${idx}. <@${entry.userId}> : [${entry.reacts}](${entry.messageUrl})`);
Expand Down

0 comments on commit 65d1b9a

Please sign in to comment.