Skip to content
This repository has been archived by the owner on Dec 2, 2022. It is now read-only.

Commit

Permalink
Better role count (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanaelhoun authored Feb 10, 2021
1 parent 9ff646f commit aa65cf7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
21 changes: 16 additions & 5 deletions bot/cogs/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,26 @@ async def show(self, ctx: commands.Context):

members = sorted(ctx.guild.members, key=lambda x: len(x.roles), reverse=True)

description = STR.ROLE_SHOW_INTRO
for member in members:
unique_roles_nb = sum(len(r.members) == 1 for r in member.roles)

description += (
STR.ROLE_SHOW_ITEM.format(
member.display_name,
len(member.roles) - 1,
unique_roles_nb,
)
+ "\n"
)

embed = discord.Embed(
description="\n".join(
STR.ROLE_SHOW_ITEM.format(m.display_name, Pluralizer(len(m.roles)))
for m in members
),
description="```\n" + description + "\n```",
)

await ctx.send(
STR.ROLE_SHOW_INTRO.format(Pluralizer(len(ctx.guild.roles))), embed=embed
STR.ROLE_SHOW_TEXT.format(Pluralizer(len(ctx.guild.roles))),
embed=embed,
)


Expand Down
12 changes: 8 additions & 4 deletions bot/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,14 @@ class Strings:
)
ROLE_CREATE_ERR_EXISTING = EM_WARN + "Le rôle {} existe déjà, la preuve!"


ROLE_SHOW_INTRO = ":label: Il y a un total de {:N rôle/s} sur ce serveur !"
ROLE_SHOW_ITEM = "- {} ({:N rôle/s})"

ROLE_SHOW_TEXT = ":label: Il y a un total de {:N rôle/s} sur ce serveur !"
ROLE_SHOW_INTRO = (
""
+ "|==============================|=======|=======|\n"
+ "| Nom | Total |Uniques|\n"
+ "|==============================|=======|=======|\n"
)
ROLE_SHOW_ITEM = "|{:30s}|{:7d}|{:7d}|"

# Commands group : utilities.random()
RANDOM_ERR_WRONG_NB_PER_TEAM = (
Expand Down

0 comments on commit aa65cf7

Please sign in to comment.