Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for GET invite endpoint (#804)
* feat: Add has_public_flag to User model * uhh * feat: Add GET Invite endpoint support (WIP) * Remove stuff that shouldn't have been committed * Update slotting * Revert "Update slotting" This reverts commit 66b0510. * Small reformat and documenting * Document new slots in Invite model * Move delete_invite and add .pyi file for InviteRequest * Fix typo and add InviteRequest to client.pyi * Add url property to invite model * Note: API is broken * Update url property * Remove accidental comment * Remove small eyesore * ci: correct from checks. * Update interactions/api/http/invite.py Co-authored-by: EdVraz <88881326+EdVraz@users.noreply.github.com> * Update interactions/api/models/guild.py Co-authored-by: EdVraz <88881326+EdVraz@users.noreply.github.com> * ci: correct from checks. * ci: correct from checks. * Remove unused imports Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: EdVraz <88881326+EdVraz@users.noreply.github.com>
- Loading branch information
1 parent
17a3d6d
commit 9f7f310
Showing
7 changed files
with
94 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from typing import Optional | ||
|
||
from ...api.cache import Cache | ||
from .request import _Request | ||
from .route import Route | ||
|
||
__all__ = ["InviteRequest"] | ||
|
||
|
||
class InviteRequest: | ||
_req = _Request | ||
cache: Cache | ||
|
||
def __init__(self) -> None: | ||
pass | ||
|
||
async def get_invite( | ||
self, | ||
invite_code: str, | ||
with_counts: bool = None, | ||
with_expiration: bool = None, | ||
guild_scheduled_event_id: int = None, | ||
) -> dict: | ||
""" | ||
Gets an invite using its code. | ||
.. note:: with_expiration is currently broken, the API will always return expiration_date. | ||
:param invite_code: A string representing the invite code. | ||
:param with_counts: Whether approximate_member_count and approximate_presence_count are returned. | ||
:param with_expiration: Whether the invite's expiration is returned. | ||
:param guild_scheduled_event_id: A guild scheduled event's ID. | ||
""" | ||
params_set = { | ||
"with_counts=true" if with_counts else None, | ||
"with_expiration=false" if not with_expiration else None, | ||
f"guild_scheduled_event_id={guild_scheduled_event_id}" | ||
if guild_scheduled_event_id | ||
else None, | ||
} | ||
final = "&".join([item for item in params_set if item is not None]) | ||
|
||
return await self._req.request( | ||
Route("GET", f"/invites/{invite_code}{'?' + final if final is not None else ''}") | ||
) | ||
|
||
async def delete_invite(self, invite_code: str, reason: Optional[str] = None) -> dict: | ||
""" | ||
Delete an invite. | ||
:param invite_code: The code of the invite to delete | ||
:param reason: Reason to show in the audit log, if any. | ||
:return: The deleted invite object | ||
""" | ||
return await self._req.request(Route("DELETE", f"/invites/{invite_code}"), reason=reason) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from typing import Optional | ||
from .request import _Request | ||
from ...api.cache import Cache | ||
|
||
class InviteRequest: | ||
|
||
_req: _Request | ||
cache: Cache | ||
|
||
def __init__(self) -> None: ... | ||
async def get_invite( | ||
self, | ||
invite_code: str, | ||
with_counts: bool = None, | ||
with_expiration: bool = None, | ||
guild_scheduled_event_id: int = None | ||
) -> dict: ... | ||
async def delete_invite(self, invite_code: str, reason: Optional[str] = None) -> dict: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters