From ed0bdeb4d8357d574928361b851a89f482c2967c Mon Sep 17 00:00:00 2001 From: shiftinv Date: Mon, 9 Oct 2023 14:18:09 +0200 Subject: [PATCH] fix: handle converter classes --- disnake/ext/commands/params.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/disnake/ext/commands/params.py b/disnake/ext/commands/params.py index 330c3adf9a..cddbda01c0 100644 --- a/disnake/ext/commands/params.py +++ b/disnake/ext/commands/params.py @@ -10,6 +10,7 @@ import itertools import math import sys +import types from abc import ABC, abstractmethod from dataclasses import dataclass from enum import Enum, EnumMeta @@ -755,7 +756,12 @@ def parse_annotation(self, annotation: Any, converter_mode: bool = False) -> boo return True def parse_converter_annotation(self, converter: Callable, fallback_annotation: Any) -> None: - _, parameters = isolate_self(get_signature_parameters(converter)) + if isinstance(converter, (types.FunctionType, types.MethodType)): + converter_func = converter + else: + # if converter isn't a function/method, it should be a callable object/type + converter_func = converter.__call__ + _, parameters = isolate_self(get_signature_parameters(converter_func)) if len(parameters) != 1: raise TypeError(