Check if converter is a class before trying to instantiate it

This commit is contained in:
Ben 2020-05-17 03:28:04 +01:00
parent 03a22a28b7
commit dbf7e4d35e

View File

@ -472,10 +472,11 @@ def get_converter(component):
async def do_conversion(converter, ctx):
if not isinstance(converter, IConverter) and issubclass(converter, IConverter):
converter = converter()
if isinstance(converter, IConverter):
if asyncio.iscoroutinefunction(converter.convert):
return await converter.convert(ctx)
return converter.convert(ctx)
if inspect.isclass(converter):
if not isinstance(converter, IConverter) and issubclass(converter, IConverter):
converter = converter()
if isinstance(converter, IConverter):
if asyncio.iscoroutinefunction(converter.convert):
return await converter.convert(ctx)
return converter.convert(ctx)
return converter(ctx.argument)