Repository: hikari-py/hikari
Pull request #1330 (2022-10-28 09:24:21)

Support specifying `with_counts` and `with_expiration` in `RESTClient.fetch_invite`
### Summary
API docs mention that [Get Invite (`/invites/{invite.code}`)](https://discord.com/developers/docs/resources/invite#get-invite) has three parameters - `with_counts`, `with_expiration`, and `guild_scheduled_event_id`. The first two are hardcoded to `true` when the rest client's `.fetch_invite()` method is used (and makes no reference to the third).

I have changed the method to default these two parameters to true, while still allowing them to be changed to false (although I'm not sure why anyone would want them to be false). It does reduce the chance for confusion though, as it wasn't immediately clear that the function already returned these two values.

### Checklist
<!-- Make sure to tick all the following boxes by putting an `x` in between (like this `[x]`) -->
- [x] I have run `nox` and all the pipelines have passed.
- [x] 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)
-->
None



Patch:
diff --git a/changes/1330.doc.md b/changes/1330.doc.md
new file mode 100644
index 00000000..2a6313d5
--- /dev/null
+++ b/changes/1330.doc.md
@@ -0,0 +1,1 @@
+Support specifying `with_counts` and `with_expiration` in `RESTClient.fetch_invite`
diff --git a/changes/1334.feature.md b/changes/1334.feature.md
new file mode 100644
index 00000000..cd6bbbb0
--- /dev/null
+++ b/changes/1334.feature.md
@@ -0,0 +1,1 @@
+Add `MANAGE_EVENTS` permission to `hikari.Permissions`
diff --git a/dev-requirements/flake8.txt b/dev-requirements/flake8.txt
index 472b8d20..be66ef79 100644
--- a/dev-requirements/flake8.txt
+++ b/dev-requirements/flake8.txt
@@ -6,9 +6,9 @@ flake8==5.0.4
 flake8-bandit~=4.1.1                    # runs bandit
 flake8-black==0.3.3                     # runs black
 flake8-broken-line==0.6.0               # forbey "\" linebreaks
-flake8-builtins==2.0.0                  # builtin shadowing checks
+flake8-builtins==2.0.1                  # builtin shadowing checks
 flake8-coding==1.3.2                    # coding magic-comment detection
-flake8-comprehensions==3.10.0           # comprehension checks
+flake8-comprehensions==3.10.1           # comprehension checks
 flake8-docstrings==1.6.0                # pydocstyle support
 flake8-executable==2.1.2                # shebangs
 flake8-fixme==1.1.1                     # "fix me" counter
diff --git a/dev-requirements/pyright.txt b/dev-requirements/pyright.txt
index 3e2d420b..bd16c09e 100644
--- a/dev-requirements/pyright.txt
+++ b/dev-requirements/pyright.txt
@@ -1,1 +1,1 @@
-pyright==1.1.277
+pyright==1.1.278
diff --git a/dev-requirements/slotscheck.txt b/dev-requirements/slotscheck.txt
index 8f35fb09..aca35f68 100644
--- a/dev-requirements/slotscheck.txt
+++ b/dev-requirements/slotscheck.txt
@@ -1,1 +1,1 @@
-slotscheck==0.15.0
+slotscheck==0.16.0
diff --git a/hikari/api/rest.py b/hikari/api/rest.py
index 38e1597e..fea1d4fb 100644
--- a/hikari/api/rest.py
+++ b/hikari/api/rest.py
@@ -2765,7 +2765,9 @@ async def fetch_gateway_bot_info(self) -> sessions.GatewayBotInfo:
         """
 
     @abc.abstractmethod
-    async def fetch_invite(self, invite: typing.Union[invites.InviteCode, str]) -> invites.Invite:
+    async def fetch_invite(
+        self, invite: typing.Union[invites.InviteCode, str], with_counts: bool = True, with_expiration: bool = True
+    ) -> invites.Invite:
         """Fetch an existing invite.
 
         Parameters
@@ -2773,6 +2775,14 @@ async def fetch_invite(self, invite: typing.Union[invites.InviteCode, str]) -> i
         invite : typing.Union[hikari.invites.InviteCode, builtins.str]
             The invite to fetch. This may be an invite object or
             the code of an existing invite.
+        with_counts : builtins.bool
+            Whether the invite should contain the approximate member counts.
+
+            Defaults to `builtins.True`.
+        with_expiration: builtins.bool
+            Whether the invite should contain the expiration date.
+
+            Defaults to `builtins.True`.
 
         Returns
         -------
diff --git a/hikari/impl/rest.py b/hikari/impl/rest.py
index 80f5160e..f9650892 100644
--- a/hikari/impl/rest.py
+++ b/hikari/impl/rest.py
@@ -1982,11 +1982,13 @@ async def fetch_gateway_bot_info(self) -> sessions.GatewayBotInfo:
         assert isinstance(response, dict)
         return self._entity_factory.deserialize_gateway_bot_info(response)
 
-    async def fetch_invite(self, invite: typing.Union[invites.InviteCode, str]) -> invites.Invite:
+    async def fetch_invite(
+        self, invite: typing.Union[invites.InviteCode, str], with_counts: bool = True, with_expiration: bool = True
+    ) -> invites.Invite:
         route = routes.GET_INVITE.compile(invite_code=invite if isinstance(invite, str) else invite.code)
         query = data_binding.StringMapBuilder()
-        query.put("with_counts", True)
-        query.put("with_expiration", True)
+        query.put("with_counts", with_counts)
+        query.put("with_expiration", with_expiration)
         response = await self._request(route, query=query)
         assert isinstance(response, dict)
         return self._entity_factory.deserialize_invite(response)
diff --git a/hikari/permissions.py b/hikari/permissions.py
index 86808fb6..ef8f06a6 100644
--- a/hikari/permissions.py
+++ b/hikari/permissions.py
@@ -246,6 +246,9 @@ class Permissions(enums.Flag):
         without warning.
     """
 
+    MANAGE_EVENTS = 1 << 33
+    """Allows for creating, editing, and deleting scheduled events	"""
+
     MANAGE_THREADS = 1 << 34
     """Allows for deleting and archiving threads, and viewing all private threads.
 


Test patch:
diff --git a/tests/hikari/impl/test_rest.py b/tests/hikari/impl/test_rest.py
index ea94ca0f..c04e9964 100644
--- a/tests/hikari/impl/test_rest.py
+++ b/tests/hikari/impl/test_rest.py
@@ -3442,10 +3442,9 @@ async def test_fetch_invite(self, rest_client):
         rest_client._request = mock.AsyncMock(return_value={"code": "Jx4cNGG"})
         rest_client._entity_factory.deserialize_invite = mock.Mock(return_value=return_invite)
 
-        assert await rest_client.fetch_invite(input_invite) == return_invite
-
+        assert await rest_client.fetch_invite(input_invite, with_counts=True, with_expiration=False) == return_invite
         rest_client._request.assert_awaited_once_with(
-            expected_route, query={"with_counts": "true", "with_expiration": "true"}
+            expected_route, query={"with_counts": "true", "with_expiration": "false"}
         )
         rest_client._entity_factory.deserialize_invite.assert_called_once_with({"code": "Jx4cNGG"})
 
diff --git a/tests/hikari/test_permissions.py b/tests/hikari/test_permissions.py
index 912f466e..fd96424b 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 == 2190433320959
+        assert all_perms == 2199023255551