mirror of
https://github.com/stijndcl/didier.git
synced 2026-04-07 15:48:29 +02:00
Add percentage to Message counter & leaderboard
This commit is contained in:
parent
f25bb468b4
commit
6a946559e2
3 changed files with 18 additions and 4 deletions
|
|
@ -10,7 +10,6 @@ import math
|
|||
import requests
|
||||
|
||||
|
||||
|
||||
# TODO some sort of general leaderboard because all of them are the same
|
||||
class Leaderboards(commands.Cog):
|
||||
|
||||
|
|
@ -156,15 +155,20 @@ class Leaderboards(commands.Cog):
|
|||
async def messages(self, ctx):
|
||||
s = stats.getAllRows()
|
||||
boardTop = []
|
||||
|
||||
message_count = stats.getTotalMessageCount()
|
||||
|
||||
for i, user in enumerate(sorted(s, key=lambda x: x[11], reverse=True)):
|
||||
if int(user[11]) == 0:
|
||||
break
|
||||
|
||||
perc = round(int(user[11]) * 100 / message_count, 2)
|
||||
|
||||
name = self.utilsCog.getDisplayName(ctx, user[0])
|
||||
if int(user[0]) == int(ctx.author.id):
|
||||
boardTop.append("**{} ({:,})**".format(name, round(int(user[11]))))
|
||||
boardTop.append("**{} ({:,} | {}%)**".format(name, round(int(user[11])), perc))
|
||||
else:
|
||||
boardTop.append("{} ({:,})".format(name, round(int(user[11]))))
|
||||
boardTop.append("{} ({:,} | {}%)".format(name, round(int(user[11])), perc))
|
||||
await self.startPaginated(ctx, boardTop, "Messages Leaderboard")
|
||||
|
||||
@leaderboard.command(name="Muttn", aliases=["M", "Mutn", "Mutten"], hidden=True)
|
||||
|
|
|
|||
|
|
@ -22,9 +22,13 @@ class Xp(commands.Cog):
|
|||
|
||||
target_stats = stats.getOrAddUser(target.id)
|
||||
|
||||
message_count = stats.getTotalMessageCount()
|
||||
|
||||
perc = round(int(target_stats[11]) * 100/message_count, 2)
|
||||
|
||||
embed = discord.Embed(colour=discord.Colour.blue())
|
||||
embed.set_author(name=target.display_name, icon_url=target.avatar_url)
|
||||
embed.add_field(name="Aantal Berichten", value="{}".format(int(target_stats[11])))
|
||||
embed.add_field(name="Aantal Berichten", value="{} ({}%)".format(int(target_stats[11]), perc))
|
||||
embed.add_field(name="Level", value=str(xp.calculate_level(target_stats[12])))
|
||||
embed.add_field(name="XP", value="{:,}".format(int(target_stats[12])))
|
||||
embed.set_footer(text="*Sinds Didier 2.0 Launch")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue