sir-lancebot icon indicating copy to clipboard operation
sir-lancebot copied to clipboard

Global Leaderboard

Open Shivansh-007 opened this issue 4 years ago • 1 comments

Relevant Issues

Closes #627

Description

This implements the global leaderboard command, it is basically a leaderboard for all the games together, if you win the coinflip, you get some points, the points you get in the trivia quiz gets added here, etc.

This feature makes use of Redis Caches (two per game) to store the game leaderboards, one being the overall leaderboard (total) and the second being the per day leaderboard which gets cleared every day at midnight UTC through a discord task loop. The overall/total leaderboard would have an additional suffix -total at the end of its cache so that it doesn't clash with the per-day leaderboard. The leaderboards are currently based on the cog qualified name, I will be adding support for getting it with the command name. The leaderboards can be initialised for a cog with the help of the Bot method ensure_leaderboard which takes in the Cog object you want to make the leaderboard for.

Currently, I have only added a helper function increment_points, if there is a need for a util function to decrement points, it can be done.

To interact with the leaderboard as a user, I have added a leaderboard cog that allows you to view per day leaderboards (overall and for a specific game) and the overall leaderboard (overall and for a specific game). It also adds an additional administrator command which can be used to clear the leaderboard if needed.

I have currently taken the coin thumbnail image as a discord image link, it would be updated once @Sn4u 's design gets finalised and merged into the branding repository.

Clear

Screenshot from 2021-10-27 06-41-45

Leaderboard (old - my preference)

Screenshot from 2021-10-27 06-42-35

Leaderboard (new - 1c9c495 - others in dev-contrib)

Screenshot from 2021-11-05 17-27-51

ToDo

  • [ ] Add leaderboard support to all game/fun cogs. This would be done at a later stage once the core functionality gets reviewed. I have added an example (coinflip command) so the reviewers can test the code easily and know how it works.

Did you:

Shivansh-007 avatar Oct 27 '21 01:10 Shivansh-007

@Bluenix2 Would you perhaps like to take over this PR?

Xithrius avatar Mar 23 '22 00:03 Xithrius

I'll be closing this PR due to staleness.

If anyone would like to pick up this PR, feel free to ping me so I can assign, along with the PR getting re-opened.

Xithrius avatar Aug 18 '22 23:08 Xithrius