[commands] ColourConverter raises if value is out of range

changes make the `ext.commands.ColourConverter` Converter fail when
user input is outside the acceptable value range 0x000000 - 0xFFFFFF
This commit is contained in:
Joshua B 2019-03-18 16:20:19 +10:00 committed by Rapptz
parent 2ce42b5b50
commit d221ca5f7d

View File

@ -294,6 +294,8 @@ class ColourConverter(Converter):
arg = arg[1:]
try:
value = int(arg, base=16)
if not (0 <= value <= 0xFFFFFF):
raise BadArgument('Colour "{}" is invalid.'.format(arg))
return discord.Colour(value=value)
except ValueError:
method = getattr(discord.Colour, arg.replace(' ', '_'), None)