diff options
-rw-r--r-- | bot/cogs/information.py | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/bot/cogs/information.py b/bot/cogs/information.py index 2dd56333f..624097eb1 100644 --- a/bot/cogs/information.py +++ b/bot/cogs/information.py @@ -1,9 +1,10 @@ import colorsys import logging import textwrap +import typing -from discord import CategoryChannel, Colour, Embed, Member, Role, TextChannel, VoiceChannel -from discord.ext.commands import Bot, Cog, Context, Greedy, command +from discord import CategoryChannel, Colour, Embed, Member, Role, TextChannel, VoiceChannel, utils +from discord.ext.commands import Bot, Cog, Context, command from bot.constants import Channels, Emojis, MODERATION_ROLES, STAFF_ROLES from bot.decorators import InChannelCheckFailure, with_role @@ -53,13 +54,30 @@ class Information(Cog): @with_role(*MODERATION_ROLES) @command(name="role") - async def role_info(self, ctx: Context, roles: Greedy[Role]): + async def role_info(self, ctx: Context, *roles: typing.Union[Role, str]): """ 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: + parsed_roles = [] + + for role_name in roles: + if isinstance(role_name, Role): + # Role conversion has already succeeded + parsed_roles.append(role_name) + continue + + role = utils.find(lambda r: r.name.lower() == role_name.lower(), ctx.guild.roles) + + if not role: + await ctx.send(f":x: Could not convert `{role_name}` to a role") + continue + + parsed_roles.append(role) + + + for role in parsed_roles: embed = Embed( title=f"{role.name} info", colour=role.colour, |