From ec83bbc22e7df2fa2beda98685ca0313dcc340c1 Mon Sep 17 00:00:00 2001 From: Middledot <78228142+Middledot@users.noreply.github.com> Date: Sun, 29 Aug 2021 15:45:57 -0400 Subject: [PATCH 1/3] \*extended mmmh\* --- discord/commands.py | 37 ++----------------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/discord/commands.py b/discord/commands.py index 6e0bf6c5af..626ed94350 100644 --- a/discord/commands.py +++ b/discord/commands.py @@ -32,6 +32,7 @@ from .member import Member from .abc import GuildChannel from .role import Role +from .enums import SlashCommandOptionType class SlashCommand: type = 1 @@ -80,40 +81,6 @@ def __eq__(self, other): and other.description == self.description ) -class SlashCommandOptionType(Enum): - custom = 0 - #sub_command = 1 - #sub_command_group = 2 - string = 3 - integer = 4 - boolean = 5 - user = 6 - channel = 7 - role = 8 - mentionable = 9 - number = 10 - - @classmethod - def from_datatype(cls, datatype): - if isinstance(datatype, str): - return cls.string - if isinstance(datatype, str): - return cls.integer - if isinstance(datatype, str): - return cls.boolean - if isinstance(datatype, Member): - return cls.user - if isinstance(datatype, GuildChannel): - return cls.channel - if isinstance(datatype, Role): - return cls.role - if isinstance(datatype, None): # FIXME uhm - return cls.mentionable - if isinstance(datatype, float): - return cls.number - return cls.custom - - class Option: def __init__(self, type, /, **kwargs): self.name = kwargs.pop("name", None) @@ -138,7 +105,7 @@ def __init__(self, name, value=None): self.value = value or name def to_dict(self): return { - "name":self.name", + "name":self.name, "value":self.value } From 002326b2d7f54b5acf22b653bc1c4adc1a9b1457 Mon Sep 17 00:00:00 2001 From: Middledot <78228142+Middledot@users.noreply.github.com> Date: Sun, 29 Aug 2021 15:47:24 -0400 Subject: [PATCH 2/3] Moved SlashCommandOptionType from .commands here --- discord/enums.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/discord/enums.py b/discord/enums.py index af8ee2b0a0..0b44220109 100644 --- a/discord/enums.py +++ b/discord/enums.py @@ -588,6 +588,39 @@ class NSFWLevel(Enum, comparable=True): safe = 2 age_restricted = 3 +class SlashCommandOptionType(Enum): + custom = 0 + #sub_command = 1 + #sub_command_group = 2 + string = 3 + integer = 4 + boolean = 5 + user = 6 + channel = 7 + role = 8 + mentionable = 9 + number = 10 + + @classmethod + def from_datatype(cls, datatype): + if isinstance(datatype, str): + return cls.string + if isinstance(datatype, str): + return cls.integer + if isinstance(datatype, str): + return cls.boolean + if isinstance(datatype, Member): + return cls.user + if isinstance(datatype, GuildChannel): + return cls.channel + if isinstance(datatype, Role): + return cls.role + if isinstance(datatype, None): # FIXME uhm + return cls.mentionable + if isinstance(datatype, float): + return cls.number + return cls.custom + T = TypeVar('T') From 6d86e62d8d4550532812aadac8c674a15097944a Mon Sep 17 00:00:00 2001 From: Middledot <78228142+Middledot@users.noreply.github.com> Date: Sun, 29 Aug 2021 15:51:39 -0400 Subject: [PATCH 3/3] deleted mentionable from `from_datatype` because it doesn't(?) have a datatype equivalent --- discord/enums.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/discord/enums.py b/discord/enums.py index 0b44220109..a95264e282 100644 --- a/discord/enums.py +++ b/discord/enums.py @@ -615,8 +615,6 @@ def from_datatype(cls, datatype): return cls.channel if isinstance(datatype, Role): return cls.role - if isinstance(datatype, None): # FIXME uhm - return cls.mentionable if isinstance(datatype, float): return cls.number return cls.custom