diff options
author | 2019-09-21 20:31:29 +0100 | |
---|---|---|
committer | 2019-09-21 20:31:29 +0100 | |
commit | a07366631888d372abc58759418cddafce9bdc9e (patch) | |
tree | 4abecb450fe1aec7ec9f8056d3e745c1933babc0 | |
parent | Fix date formatting bug in infraction search (diff) |
Add role info command
-rw-r--r-- | bot/cogs/information.py | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/bot/cogs/information.py b/bot/cogs/information.py index c4aff73b8..f05505902 100644 --- a/bot/cogs/information.py +++ b/bot/cogs/information.py @@ -1,8 +1,9 @@ +import colorsys import logging import textwrap -from discord import CategoryChannel, Colour, Embed, Member, TextChannel, VoiceChannel -from discord.ext.commands import Bot, Cog, Context, command +from discord import CategoryChannel, Colour, Embed, Member, Role, TextChannel, VoiceChannel +from discord.ext.commands import Bot, Cog, Context, Greedy, command from bot.constants import Channels, Emojis, MODERATION_ROLES, STAFF_ROLES from bot.decorators import InChannelCheckFailure, with_role @@ -50,6 +51,36 @@ class Information(Cog): await ctx.send(embed=embed) + @with_role(*MODERATION_ROLES) + @command(name="role") + async def role_info(self, ctx: Context, roles: Greedy[Role]): + """ + Return information on a role or list of roles. + + To specify multiple roles just add to the arguments, delimit roles with spaces in them using quotation marks. + """ + for role in roles: + embed = Embed( + title=f"{role.name} info", + colour=role.colour, + ) + + embed.add_field(name="ID", value=role.id, inline=True) + + embed.add_field(name="Colour (RGB)", value=f"#{role.colour.value:0>6x}", inline=True) + + h, s, v = colorsys.rgb_to_hsv(*role.colour.to_rgb()) + + embed.add_field(name="Colour (HSV)", value=f"{h:.2f} {s:.2f} {v:.2f}", inline=True) + + embed.add_field(name="Member count", value=len(role.members), inline=True) + + embed.add_field(name="Position", value=role.position) + + embed.add_field(name="Permission code", value=role.permissions.value, inline=True) + + await ctx.send(embed=embed) + @command(name="server", aliases=["server_info", "guild", "guild_info"]) async def server_info(self, ctx: Context): """ |