Repository: hikari-py/hikari
Pull request #798 (2021-09-26 07:03:41)

Add new START_EMBEDDED_ACTIVITIES permission

davfsa: Testing update blocked by #799 due to conflicts

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7ca446e1..f7dbc841 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -48,7 +48,7 @@ Bugfixes
   - `is_webhook` will now return `undefined.UNDEFINED` if the information is not available
   - Fix logic in `is_human` to account for the changes in the typing
   - Set `PartialMessage.member` to `undefined.UNDEFINED` when Discord edit the message to display an embed/attachment ([#783](https://github.com/hikari-py/hikari/issues/783))
-- `CommandOption.value` will now be cast to a `Snowflake` for types 6-9 ([#785](https://github.com/hikari-py/hikari/issues/785))
+- `CommandInteractionOption.value` will now be cast to a `Snowflake` for types 6-9 ([#785](https://github.com/hikari-py/hikari/issues/785))
 
 
 Improved Documentation
diff --git a/changes/798.feature.md b/changes/798.feature.md
new file mode 100644
index 00000000..9f2ed156
--- /dev/null
+++ b/changes/798.feature.md
@@ -0,0 +1,1 @@
+Add new `START_EMBEDDED_ACTIVITIES` permission
diff --git a/changes/800.feature.md b/changes/800.feature.md
new file mode 100644
index 00000000..7adf3e8e
--- /dev/null
+++ b/changes/800.feature.md
@@ -0,0 +1,1 @@
+Support new `channel_types` field in `CommandOption`
diff --git a/hikari/commands.py b/hikari/commands.py
index cc42d500..b0f2f326 100644
--- a/hikari/commands.py
+++ b/hikari/commands.py
@@ -44,6 +44,7 @@
 from hikari.internal import enums
 
 if typing.TYPE_CHECKING:
+    from hikari import channels
     from hikari import guilds
 
 
@@ -136,6 +137,14 @@ class CommandOption:
     options: typing.Optional[typing.Sequence[CommandOption]] = attr.field(default=None, repr=False)
     """Sequence of up to (and including) 25 of the options for this command option."""
 
+    channel_types: typing.Optional[typing.Sequence[typing.Union[channels.ChannelType, int]]] = attr.field(
+        default=None, repr=False
+    )
+    """The channel types that this option will accept.
+
+    If `builtins.None`, then all channel types will be accepted.
+    """
+
 
 @attr_extensions.with_copy
 @attr.define(hash=True, kw_only=True, weakref_slot=False)
diff --git a/hikari/impl/entity_factory.py b/hikari/impl/entity_factory.py
index d464b999..e5fb7007 100644
--- a/hikari/impl/entity_factory.py
+++ b/hikari/impl/entity_factory.py
@@ -1669,6 +1669,10 @@ def _deserialize_command_option(self, payload: data_binding.JSONObject) -> comma
         if raw_options := payload.get("options"):
             suboptions = [self._deserialize_command_option(option) for option in raw_options]
 
+        channel_types: typing.Optional[typing.Sequence[typing.Union[channel_models.ChannelType, int]]] = None
+        if raw_channel_types := payload.get("channel_types"):
+            channel_types = [channel_models.ChannelType(channel_type) for channel_type in raw_channel_types]
+
         return commands.CommandOption(
             type=commands.OptionType(payload["type"]),
             name=payload["name"],
@@ -1676,6 +1680,7 @@ def _deserialize_command_option(self, payload: data_binding.JSONObject) -> comma
             is_required=payload.get("required", False),
             choices=choices,
             options=suboptions,
+            channel_types=channel_types,
         )
 
     def deserialize_command(
@@ -1889,6 +1894,9 @@ def serialize_command_option(self, option: commands.CommandOption) -> data_bindi
             "required": option.is_required,
         }
 
+        if option.channel_types is not None:
+            payload["channel_types"] = option.channel_types
+
         if option.choices is not None:
             payload["choices"] = [{"name": choice.name, "value": choice.value} for choice in option.choices]
 
diff --git a/hikari/messages.py b/hikari/messages.py
index d79523ac..4bc194c3 100644
--- a/hikari/messages.py
+++ b/hikari/messages.py
@@ -608,7 +608,7 @@ class ButtonComponent(PartialComponent):
     """Custom or unicode emoji which appears on the button."""
 
     custom_id: typing.Optional[str] = attr.field(hash=True)
-    """Developer defined identifier for this button (will be >= 100 characters).
+    """Developer defined identifier for this button (will be <= 100 characters).
 
     !!! note
         This is required for the following button styles:
@@ -656,7 +656,7 @@ class SelectMenuComponent(PartialComponent):
     """
 
     custom_id: str = attr.field(hash=True)
-    """Developer defined identifier for this menu (will be >= 100 characters)."""
+    """Developer defined identifier for this menu (will be <= 100 characters)."""
 
     options: typing.Sequence[SelectMenuOption] = attr.field(eq=False)
     """Sequence of up to 25 of the options set for this menu."""
diff --git a/hikari/permissions.py b/hikari/permissions.py
index 92548cd7..5e94e924 100644
--- a/hikari/permissions.py
+++ b/hikari/permissions.py
@@ -276,6 +276,9 @@ class Permissions(enums.Flag):
     SEND_MESSAGES_IN_THREADS = 1 << 38
     """Allows for sending messages in threads."""
 
+    START_EMBEDDED_ACTIVITIES = 1 << 39
+    """Allows for launching activities (applications with the `EMBEDDED` flag) in a voice channel"""
+
     @classmethod
     def all_permissions(cls) -> Permissions:
         """Get an instance of `Permissions` with all the known permissions.


Test patch:
diff --git a/tests/hikari/impl/test_entity_factory.py b/tests/hikari/impl/test_entity_factory.py
index 90dcc97c..5b47d356 100644
--- a/tests/hikari/impl/test_entity_factory.py
+++ b/tests/hikari/impl/test_entity_factory.py
@@ -3091,6 +3091,25 @@ def test_deserialize_interaction_handles_unknown_type(self, entity_factory_impl)
         with pytest.raises(errors.UnrecognisedEntityError):
             entity_factory_impl.deserialize_interaction({"type": -999})
 
+    def test_serialize_command_option_with_channel_type(self, entity_factory_impl):
+        option = commands.CommandOption(
+            type=commands.OptionType.INTEGER,
+            name="a name",
+            description="go away",
+            is_required=True,
+            channel_types=[channel_models.ChannelType.GUILD_STAGE, channel_models.ChannelType.GUILD_TEXT, 100],
+        )
+
+        result = entity_factory_impl.serialize_command_option(option)
+
+        assert result == {
+            "type": 4,
+            "name": "a name",
+            "description": "go away",
+            "required": True,
+            "channel_types": [13, 0, 100],
+        }
+
     def test_serialize_command_option_with_choices(self, entity_factory_impl):
         option = commands.CommandOption(
             type=commands.OptionType.INTEGER,
diff --git a/tests/hikari/test_permissions.py b/tests/hikari/test_permissions.py
index 4ff7cbad..ca33a84d 100644
--- a/tests/hikari/test_permissions.py
+++ b/tests/hikari/test_permissions.py
@@ -27,4 +27,4 @@ def test_all_permissions(self):
         all_perms = permissions.Permissions.all_permissions()
 
         assert isinstance(all_perms, permissions.Permissions)
-        assert all_perms == 541165879295
+        assert all_perms == 1090921693183