diff --git a/interactions/api/gateway/ratelimit.py b/interactions/api/gateway/ratelimit.py index 01e30466f..2e538eefd 100644 --- a/interactions/api/gateway/ratelimit.py +++ b/interactions/api/gateway/ratelimit.py @@ -6,6 +6,8 @@ log = logging.getLogger("gateway.ratelimit") +__all__ = ("WSRateLimit",) + class WSRateLimit: """ diff --git a/interactions/api/models/gw.py b/interactions/api/models/gw.py index a56412723..bdf123c27 100644 --- a/interactions/api/models/gw.py +++ b/interactions/api/models/gw.py @@ -132,7 +132,7 @@ class ApplicationCommandPermission(DictSerializerMixin): .. code-block:: python - interactions.Permission( + interactions.ApplicationCommandPermission( id=1234567890, type=interactions.PermissionType.USER, permission=True, @@ -147,9 +147,6 @@ class ApplicationCommandPermission(DictSerializerMixin): type: PermissionType = field(converter=PermissionType) permission: bool = field() - def __attrs_post_init__(self): - self._json["type"] = self.type.value - @define() class ApplicationCommandPermissions(ClientSerializerMixin, IDMixin): @@ -219,7 +216,7 @@ class GuildBan(ClientSerializerMixin): """ guild_id: Snowflake = field(converter=Snowflake) - user: User = field(converter=User) + user: User = field(converter=User, add_client=True) @define() @@ -232,7 +229,7 @@ class GuildEmojis(ClientSerializerMixin): """ guild_id: Snowflake = field(converter=Snowflake) - emojis: List[Emoji] = field(converter=convert_list(Emoji)) + emojis: List[Emoji] = field(converter=convert_list(Emoji), add_client=True) @define() @@ -330,9 +327,8 @@ class GuildRole(ClientSerializerMixin): """ guild_id: Snowflake = field(converter=Snowflake) - role: Optional[Role] = field(converter=Role, default=None) + role: Optional[Role] = field(converter=Role, add_client=True, default=None) role_id: Optional[Snowflake] = field(converter=Snowflake, default=None) - guild_hashes = field() # TODO: investigate what this is. @define() diff --git a/interactions/client/context.py b/interactions/client/context.py index 16cb549c5..164f956a3 100644 --- a/interactions/client/context.py +++ b/interactions/client/context.py @@ -651,39 +651,32 @@ async def populate(self, choices: Union[Choice, List[Choice]]) -> List[Choice]: :rtype: List[Choice] """ - async def func(): - _choices: Union[list, None] = [] - - if not choices or (isinstance(choices, list) and len(choices) == 0): - _choices = None - elif isinstance(choices, Choice): - _choices.append(choices._json) - elif isinstance(choices, list) and all( - isinstance(choice, Choice) for choice in choices - ): - _choices = [choice._json for choice in choices] - elif all( - isinstance(choice, dict) and all(isinstance(x, str) for x in choice) - for choice in choices - ): - _choices = list(choices) - else: - raise LibraryException( - 6, message="Autocomplete choice items must be of type Choice" - ) - - await self._client.create_interaction_response( - token=self.token, - application_id=int(self.id), - data={ - "type": InteractionCallbackType.APPLICATION_COMMAND_AUTOCOMPLETE_RESULT.value, - "data": {"choices": _choices}, - }, - ) + _choices: Union[list, None] = [] + + if not choices or (isinstance(choices, list) and len(choices) == 0): + _choices = None + elif isinstance(choices, Choice): + _choices.append(choices._json) + elif isinstance(choices, list) and all(isinstance(choice, Choice) for choice in choices): + _choices = [choice._json for choice in choices] + elif all( + isinstance(choice, dict) and all(isinstance(x, str) for x in choice) + for choice in choices + ): + _choices = list(choices) + else: + raise LibraryException(6, message="Autocomplete choice items must be of type Choice") - return _choices + await self._client.create_interaction_response( + token=self.token, + application_id=int(self.id), + data={ + "type": InteractionCallbackType.APPLICATION_COMMAND_AUTOCOMPLETE_RESULT.value, + "data": {"choices": _choices}, + }, + ) - return await func() + return _choices @define()