Update with requested changes
This commit is contained in:
parent
ac3187f62e
commit
e84cef2607
@ -1250,10 +1250,9 @@ class Command(_BaseCommand, Generic[CogT, P, T]):
|
|||||||
annotation = str
|
annotation = str
|
||||||
origin = None
|
origin = None
|
||||||
|
|
||||||
if not required and origin is Union and annotation.__args__[-1] is type(None):
|
if not required and origin is not None and len(annotation.__args__) == 2:
|
||||||
# Unpack Optional[T] (Union[T, None]) into just T
|
# Unpack Optional[T] (Union[T, None]) into just T
|
||||||
annotation = annotation.__args__[0]
|
annotation, origin = annotation.__args__[0], None
|
||||||
origin = getattr(annotation, "__origin__", None)
|
|
||||||
|
|
||||||
option: Dict[str, Any] = {
|
option: Dict[str, Any] = {
|
||||||
"type": 3,
|
"type": 3,
|
||||||
@ -1283,9 +1282,9 @@ class Command(_BaseCommand, Generic[CogT, P, T]):
|
|||||||
if annotation in {Union[discord.Member, discord.Role], Union[MemberConverter, RoleConverter]}:
|
if annotation in {Union[discord.Member, discord.Role], Union[MemberConverter, RoleConverter]}:
|
||||||
option["type"] = 9
|
option["type"] = 9
|
||||||
|
|
||||||
elif all([issubclass(x, (discord.abc.GuildChannel, discord.abc.Messageable)) for x in annotation.__args__]):
|
elif all([arg in application_option_channel_types for arg in annotation.__args__]):
|
||||||
option["type"] = 7
|
option["type"] = 7
|
||||||
option["channel_types"] = [x for y in annotation.__args__ for x in application_option_channel_types[y]]
|
option["channel_types"] = [discord_value for arg in annotation.__args__ for discord_value in application_option_channel_types[arg]]
|
||||||
|
|
||||||
elif origin is Literal:
|
elif origin is Literal:
|
||||||
literal_values = annotation.__args__
|
literal_values = annotation.__args__
|
||||||
|
Loading…
x
Reference in New Issue
Block a user