Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support specifying with_counts and with_expiration in RESTClient.fetch_invite #1330

Merged
merged 11 commits into from
Nov 6, 2022
1 change: 1 addition & 0 deletions changes/1330.doc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve RESTClientImpl.fetch_invite() to more closely match DAPI docs
null-domain marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 7 additions & 1 deletion hikari/api/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2762,14 +2762,20 @@ 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
----------
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 approximate member counts.
with_expiration: builtins.bool
Whether the invite should contain the expiration date.
davfsa marked this conversation as resolved.
Show resolved Hide resolved

Returns
-------
Expand Down
8 changes: 5 additions & 3 deletions hikari/impl/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1960,11 +1960,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)
Expand Down