mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 20:28:38 +00:00
Allow Transformer.transform to be synchronous as well.
This commit is contained in:
parent
1f3aa377c3
commit
e9ed231a03
@ -48,7 +48,7 @@ from .errors import AppCommandError, TransformerError
|
|||||||
from .models import AppCommandChannel, AppCommandThread, Choice
|
from .models import AppCommandChannel, AppCommandThread, Choice
|
||||||
from ..channel import StageChannel, StoreChannel, VoiceChannel, TextChannel, CategoryChannel
|
from ..channel import StageChannel, StoreChannel, VoiceChannel, TextChannel, CategoryChannel
|
||||||
from ..enums import AppCommandOptionType, ChannelType
|
from ..enums import AppCommandOptionType, ChannelType
|
||||||
from ..utils import MISSING
|
from ..utils import MISSING, maybe_coroutine
|
||||||
from ..user import User
|
from ..user import User
|
||||||
from ..role import Role
|
from ..role import Role
|
||||||
from ..member import Member
|
from ..member import Member
|
||||||
@ -137,7 +137,8 @@ class CommandParameter:
|
|||||||
return choice
|
return choice
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return await self._annotation.transform(interaction, value)
|
# ParamSpec doesn't understand that transform is a callable since it's unbound
|
||||||
|
return await maybe_coroutine(self._annotation.transform, interaction, value) # type: ignore
|
||||||
except AppCommandError:
|
except AppCommandError:
|
||||||
raise
|
raise
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -224,7 +225,7 @@ class Transformer:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def transform(cls, interaction: Interaction, value: Any) -> Any:
|
async def transform(cls, interaction: Interaction, value: Any) -> Any:
|
||||||
"""|coro|
|
"""|maybecoro|
|
||||||
|
|
||||||
Transforms the converted option value into another value.
|
Transforms the converted option value into another value.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user