-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
π₯ Streak feature #3 from Pexilo/streak-feature
- Loading branch information
Showing
7 changed files
with
49 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { GuildMember } from "discord.js"; | ||
|
||
export default interface ILeaderboardUser { | ||
index: number; | ||
position: number; | ||
user: GuildMember | undefined; | ||
points: number; | ||
streak: number; | ||
whosThatResponded: { guildId: string; messageId: string; correct: boolean }[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import ILeaderboardUser from "@models/ILeaderboardUser"; | ||
|
||
export default function UserStreak( | ||
whosThatGuild: ILeaderboardUser["whosThatResponded"] | ||
): number { | ||
const last3Whosthat = whosThatGuild.slice(-3); | ||
let streak = 0; | ||
for (const entry of last3Whosthat) { | ||
if (entry.correct) { | ||
streak++; | ||
} else { | ||
streak = 0; | ||
} | ||
} | ||
return streak; | ||
} |