Browse Source

[commands] Raise BadArgument in ColourConverter when using from_hsv/rgb

Fixes #2043
pull/2049/head
Rapptz 6 years ago
parent
commit
e4de25eaab
  1. 5
      discord/ext/commands/converter.py

5
discord/ext/commands/converter.py

@ -298,8 +298,9 @@ class ColourConverter(Converter):
raise BadArgument('Colour "{}" is invalid.'.format(arg))
return discord.Colour(value=value)
except ValueError:
method = getattr(discord.Colour, arg.replace(' ', '_'), None)
if method is None or not inspect.ismethod(method):
arg = arg.replace(' ', '_')
method = getattr(discord.Colour, arg, None)
if arg.startswith('from_') or method is None or not inspect.ismethod(method):
raise BadArgument('Colour "{}" is invalid.'.format(arg))
return method()

Loading…
Cancel
Save