1
0
Fork 0
mirror of synced 2024-06-02 18:54:33 +12:00

Add a way to print info about a specific role

This commit is contained in:
phxntxm 2018-10-05 10:26:10 -05:00
parent 2395aba4f7
commit 764759b30a

View file

@ -62,12 +62,33 @@ class Roles:
@commands.group(aliases=['roles'], invoke_without_command=True) @commands.group(aliases=['roles'], invoke_without_command=True)
@commands.guild_only() @commands.guild_only()
@utils.can_run(send_messages=True) @utils.can_run(send_messages=True)
async def role(self, ctx): async def role(self, ctx, *, role: discord.Role=None):
"""This command can be used to modify the roles on the server. """This command can be used to modify the roles on the server.
Pass no subcommands and this will print the roles currently available on this server Pass no subcommands and this will print the roles currently available on this server
If you give a role as the argument then it will give some information about that role
EXAMPLE: !role EXAMPLE: !role
RESULT: A list of all your roles""" RESULT: A list of all your roles"""
if role:
# Create the embed object
opts = {
"title": role.name,
"colour": role.colour,
}
if role.managed:
opts["description"] = "This role is managed by a third party service"
embed = discord.Embed(**opts)
# Add details to it
embed.add_field(name="Created", value=role.created_at.date())
embed.add_field(name="Mentionable", value="Yes" if role.mentionable else "No")
total_members = len(role.members)
embed.add_field(name="Total members", value=str(total_members))
# If there are only a few members in this role, display them
if total_members <= 5:
embed.add_field(name="Members", value="\n".join(m.display_name for m in role.members))
await ctx.send(embed=embed)
else:
# Don't include the colour roles # Don't include the colour roles
colour_role = re.compile("Bonfire #.+") colour_role = re.compile("Bonfire #.+")
# Simply get a list of all roles in this server and send them # Simply get a list of all roles in this server and send them