feat: guild join requests - #3383
Conversation
|
Thanks for opening this pull request! This pull request can be checked-out with: git fetch origin pull/3383/head:pr-3383
git checkout pr-3383This pull request can be installed with: pip install git+https://github.com/Pycord-Development/pycord@refs/pull/3383/head |
| data["guild_id"], | ||
| ) | ||
|
|
||
| def parse_guild_join_request_create(self, data: JoinRequestCreatePayload) -> None: |
There was a problem hiding this comment.
I wonder if we still would wanna cache these...
…Development/pycord into feat/guild-join-requests
| The ID of the guild the join request belongs to. | ||
| guild: :class:`discord.Guild` | ||
| The guild the join request belongs to. | ||
| application_status: :class:`JoinRequestStatus` |
There was a problem hiding this comment.
| application_status: :class:`JoinRequestStatus` | |
| application_status: :class:`JoinRequestStatus` | :data:`None` |
| guild: :class:`discord.Guild` | ||
| The guild the join request belongs to. |
There was a problem hiding this comment.
| guild: :class:`discord.Guild` | |
| The guild the join request belongs to. |
|
|
||
| @property | ||
| def guild(self) -> Guild | None: | ||
| """Optional[:class:`discord.Guild`]: The guild the join request belongs to. |
There was a problem hiding this comment.
| """Optional[:class:`discord.Guild`]: The guild the join request belongs to. | |
| """:class:`discord.Guild` | :data:`None`: The guild the join request belongs to. |
| ---------- | ||
| action: :class:`JoinRequestAction` | ||
| The action to take on the join request. | ||
| rejection_reason: Optional[:class:`str`] |
There was a problem hiding this comment.
| rejection_reason: Optional[:class:`str`] | |
| rejection_reason: :class:`str` | :data:`None` |
vmphase
left a comment
There was a problem hiding this comment.
Please use a typechecker before pushing commits.
| def create_join_request(self, data: JoinRequestPayload) -> JoinRequest: | ||
| from .guild_join_request import JoinRequest | ||
|
|
||
| return JoinRequest(guild=self.guild, state=self.state, data=data) |
There was a problem hiding this comment.
JoinRequest no longer takes a guild kwarg; will cause a TypeError.
| return JoinRequest(guild=self.guild, state=self.state, data=data) | |
| return JoinRequest(state=self.state, data=data) |
| response: str | int | bool | None = data.get("response") | ||
| if ( | ||
| self.field_type is JoinRequestFormFieldType.MULTIPLE_CHOICE | ||
| and isinstance(response, int) | ||
| and self.choices is not None | ||
| and 0 <= response < len(self.choices) | ||
| ): | ||
| self.choice_index = response | ||
| self.response = self.choices[self.choice_index] |
There was a problem hiding this comment.
self.response only ever gets set inside the MULTIPLE_CHOICE branch. For TERMS, TEXT_INPUT and PARAGRAPH it stays None forever, even though data.get("response") may contain some value. Not sure it's intended...
| "form_responses", | ||
| "rejection_reason", | ||
| "reviewed_at", | ||
| "status", |
There was a problem hiding this comment.
The attribute is application_status, not status, which is inherited from PartialJoinRequest and doesn't need to be re-slotted here.
| "status", |
| .. versionadded:: 2.9 | ||
| If the join request has already been approved or rejected, this will raise :exc:`ValueError`. |
There was a problem hiding this comment.
Huh?
| .. versionadded:: 2.9 | |
| If the join request has already been approved or rejected, this will raise :exc:`ValueError`. | |
| .. versionadded:: 2.9 |
| ) | ||
| from .mixins import Hashable | ||
|
|
||
| __all__ = ("FormResponse", "JoinRequest") |
There was a problem hiding this comment.
| __all__ = ("FormResponse", "JoinRequest") | |
| __all__ = ("FormResponse", "JoinRequest", "PartialJoinRequest") |
| Usage :: | ||
|
|
||
| async for request in guild.join_requests(limit=250): | ||
| print(request.user, request.status) |
There was a problem hiding this comment.
| print(request.user, request.status) | |
| print(request.user, request.application_status) |
Summary
Closes #3340
This PR adds support for getting and taking action on guild join requests/applications.
API Docs: discord/discord-api-docs#8531
This adds:
PartialJoinRequest&JoinRequest&FormResponseJoinRequestStatus(Enum)JoinRequestFormFieldType(Enum)JoinRequestAction(Enum)Guild.fetch_join_requests()HTTPClient.get_guild_join_requests()&HTTPClient.action_guild_join_request()JoinRequestIteratoron_raw_guild_join_request_delete&RawGuildJoinRequestDeleteEventon_guild_join_request_createon_guild_join_request_updateCodex was used for the added iterator and documentations.
Needs testing.
Information
examples, ...).
Checklist
type: ignorecomments were used, a comment is also left explaining why.