Repository: hikari-py/hikari
Pull request #1243 (2022-08-10 11:18:24)

dm_permission defaults to True not False
Signed-off-by: Lucina <lucina@lmbyrne.dev>

### Summary
<!-- Small summary of the merge request -->

### Checklist
<!-- Make sure to tick all the following boxes by putting an `x` in between (like this `[x]`) -->
- [ ] I have run `nox` and all the pipelines have passed.
- [ ] I have made unittests according to the code I have added/modified/deleted.

### Related issues
<!--
To mention an issue use `#issue-id` and to mention a merge request use `!merge-request-id`
To close/fix an issue use `Close #issue-id` or `Fix #issue-id` (depending on the merge request)
-->



Patch:
diff --git a/changes/1243.bugfix.md b/changes/1243.bugfix.md
new file mode 100644
index 00000000..58771977
--- /dev/null
+++ b/changes/1243.bugfix.md
@@ -0,0 +1,1 @@
+`dm_permission` now correctly defaults to `True` instead of `False` when parsing command objects from Discord.
diff --git a/hikari/impl/entity_factory.py b/hikari/impl/entity_factory.py
index 56a5967d..3033ff59 100644
--- a/hikari/impl/entity_factory.py
+++ b/hikari/impl/entity_factory.py
@@ -1817,7 +1817,7 @@ def deserialize_slash_command(
             description=payload["description"],
             options=options,
             default_member_permissions=default_member_permissions,
-            is_dm_enabled=payload.get("dm_permission", False),
+            is_dm_enabled=payload.get("dm_permission", True),
             guild_id=guild_id,
             version=snowflakes.Snowflake(payload["version"]),
         )
@@ -1847,7 +1847,7 @@ def deserialize_context_menu_command(
             application_id=snowflakes.Snowflake(payload["application_id"]),
             name=payload["name"],
             default_member_permissions=default_member_permissions,
-            is_dm_enabled=payload.get("dm_permission", False),
+            is_dm_enabled=payload.get("dm_permission", True),
             guild_id=guild_id,
             version=snowflakes.Snowflake(payload["version"]),
         )


Test patch:
diff --git a/tests/hikari/impl/test_entity_factory.py b/tests/hikari/impl/test_entity_factory.py
index 7ec3fc9d..f738ffdc 100644
--- a/tests/hikari/impl/test_entity_factory.py
+++ b/tests/hikari/impl/test_entity_factory.py
@@ -3265,7 +3265,7 @@ def test_deserialize_slash_command_with_null_and_unset_values(self, entity_facto
         command = entity_factory_impl.deserialize_slash_command(payload)
 
         assert command.options is None
-        assert command.is_dm_enabled is False
+        assert command.is_dm_enabled is True
         assert isinstance(command, commands.SlashCommand)
 
     def test_deserialize_slash_command_standardizes_default_member_permissions(
@@ -3848,7 +3848,7 @@ def test_deserialize_context_menu_command_with_with_null_and_unset_values(
         command = entity_factory_impl.deserialize_context_menu_command(context_menu_command_payload)
         assert isinstance(command, commands.ContextMenuCommand)
 
-        assert command.is_dm_enabled is False
+        assert command.is_dm_enabled is True
 
     def test_deserialize_context_menu_command_default_member_permissions(
         self, entity_factory_impl, context_menu_command_payload