mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-05 01:16:21 +00:00
[commands] Allow Greedy to potentially maintain state between calls
This commit is contained in:
@ -1039,6 +1039,17 @@ class Greedy(List[T]):
|
||||
|
||||
return cls(converter=converter)
|
||||
|
||||
@property
|
||||
def constructed_converter(self) -> Any:
|
||||
# Only construct a converter once in order to maintain state between convert calls
|
||||
if (
|
||||
inspect.isclass(self.converter)
|
||||
and issubclass(self.converter, Converter)
|
||||
and not inspect.ismethod(self.converter.convert)
|
||||
):
|
||||
return self.converter()
|
||||
return self.converter
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing_extensions import Annotated as Range
|
||||
|
Reference in New Issue
Block a user