Repository: hikari-py/hikari
Pull request #1712 (2023-09-09 13:30:58)

Add `approximate_guild_count` field to own `Application`


Patch:
diff --git a/changes/1712.feature.md b/changes/1712.feature.md
new file mode 100644
index 00000000..ca623497
--- /dev/null
+++ b/changes/1712.feature.md
@@ -0,0 +1,1 @@
+Add `approximate_guild_count` field to own `Application`
diff --git a/hikari/applications.py b/hikari/applications.py
index e6472e3f..c6d62272 100644
--- a/hikari/applications.py
+++ b/hikari/applications.py
@@ -632,6 +632,9 @@ class Application(guilds.PartialApplication):
     install_parameters: typing.Optional[ApplicationInstallParameters] = attrs.field(eq=False, hash=False, repr=False)
     """Settings for the application's default in-app authorization link, if enabled."""
 
+    approximate_guild_count: int = attrs.field(eq=False, hash=False, repr=False)
+    """The approximate number of guilds this application is part of."""
+
     @property
     def cover_image_url(self) -> typing.Optional[files.URL]:
         """Rich presence cover image URL for this application, if set."""
diff --git a/hikari/impl/entity_factory.py b/hikari/impl/entity_factory.py
index aaa8fbed..b5358e2a 100644
--- a/hikari/impl/entity_factory.py
+++ b/hikari/impl/entity_factory.py
@@ -651,6 +651,7 @@ def deserialize_application(self, payload: data_binding.JSONObject) -> applicati
             custom_install_url=payload.get("custom_install_url"),
             tags=payload.get("tags") or [],
             install_parameters=install_parameters,
+            approximate_guild_count=payload["approximate_guild_count"],
         )
 
     def deserialize_authorization_information(


Test patch:
diff --git a/tests/hikari/impl/test_entity_factory.py b/tests/hikari/impl/test_entity_factory.py
index c7a2f34a..47fd133c 100644
--- a/tests/hikari/impl/test_entity_factory.py
+++ b/tests/hikari/impl/test_entity_factory.py
@@ -975,6 +975,7 @@ def application_payload(self, owner_payload, user_payload):
             "custom_install_url": "https://dontinstallme.com",
             "tags": ["i", "like", "hikari"],
             "install_params": {"scopes": ["bot", "applications.commands"], "permissions": 8},
+            "approximate_guild_count": 10000,
         }
 
     def test_deserialize_application(
@@ -1001,6 +1002,7 @@ def test_deserialize_application(
         assert application.custom_install_url == "https://dontinstallme.com"
         assert application.tags == ["i", "like", "hikari"]
         assert application.icon_hash == "iwiwiwiwiw"
+        assert application.approximate_guild_count == 10000
         # Install Parameters
         assert application.install_parameters.scopes == [
             application_models.OAuth2Scope.BOT,
@@ -1037,6 +1039,7 @@ def test_deserialize_application_with_unset_fields(self, entity_factory_impl, mo
                 "verify_key": "1232313223",
                 "flags": 0,
                 "owner": owner_payload,
+                "approximate_guild_count": 10000,
             }
         )
 
@@ -1061,6 +1064,7 @@ def test_deserialize_application_with_null_fields(self, entity_factory_impl, moc
                 "bot_require_code_grant": False,
                 "verify_key": "1232313223",
                 "flags": 0,
+                "approximate_guild_count": 10000,
             }
         )