-
-
Notifications
You must be signed in to change notification settings - Fork 496
feat: guild join requests #3383
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
Draft
Soheab
wants to merge
14
commits into
master
Choose a base branch
from
feat/guild-join-requests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
7a37aca
feat: guild join requests
Soheab 57b20aa
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 8896587
chore: fix typo in http method
Soheab c6d7506
chore: events
Soheab 321c279
Guild.fetch_join_requests -> Guild.join_requests
Soheab 8bba006
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 4d8b034
refactor: requested changes and (partial) refactor
Soheab ec90827
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] d26dd70
chore: revert BaseJoinRequest
Soheab 656bc51
Merge branch 'feat/guild-join-requests' of https://github.com/Pycord-…
Soheab d970127
chore: actioned_by_user -> actioned_by
Soheab a37897a
chore: parse choices response
Soheab 3154440
fix: duplicated guild attribute
Soheab 07c9a79
fix: duplicated guild and user attributes
Soheab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -56,6 +56,7 @@ | |||||
| ChannelType, | ||||||
| ContentFilter, | ||||||
| EntitlementOwnerType, | ||||||
| JoinRequestStatus, | ||||||
| NotificationLevel, | ||||||
| NSFWLevel, | ||||||
| OnboardingMode, | ||||||
|
|
@@ -78,6 +79,7 @@ | |||||
| AuditLogIterator, | ||||||
| BanIterator, | ||||||
| EntitlementIterator, | ||||||
| JoinRequestIterator, | ||||||
| MemberIterator, | ||||||
| ) | ||||||
| from .member import Member, VoiceState | ||||||
|
|
@@ -111,6 +113,7 @@ | |||||
| TextChannel, | ||||||
| VoiceChannel, | ||||||
| ) | ||||||
| from .guild_join_request import JoinRequest | ||||||
| from .onboarding import OnboardingPrompt | ||||||
| from .permissions import Permissions | ||||||
| from .state import ConnectionState | ||||||
|
|
@@ -4719,3 +4722,87 @@ def get_sound(self, sound_id: int) -> SoundboardSound | None: | |||||
| The sound or ``None`` if not found. | ||||||
| """ | ||||||
| return self._sounds.get(sound_id) | ||||||
|
|
||||||
| def join_requests( | ||||||
| self, | ||||||
| *, | ||||||
| status: JoinRequestStatus | None = None, | ||||||
| limit: int | None = 100, | ||||||
| before: SnowflakeTime | None = None, | ||||||
| after: SnowflakeTime | None = None, | ||||||
| ) -> JoinRequestIterator: | ||||||
| """Retrieves an :class:`.AsyncIterator` that enables receiving the guild's join requests. | ||||||
|
|
||||||
| This requires either the :attr:`~Permissions.kick_members` or :attr:`~Permissions.manage_guild` | ||||||
| permission. Apps with only :attr:`~Permissions.manage_guild` receive no join requests, but the | ||||||
| iterator's :attr:`~JoinRequestIterator.total` attribute is populated with the pending-request count | ||||||
| after its first request. | ||||||
|
|
||||||
| The :attr:`~JoinRequestIterator.total` attribute is only populated when `status` is set to | ||||||
| either ``None`` or :attr:`JoinRequestStatus.SUBMITTED`. It's always ``None`` otherwise. | ||||||
|
|
||||||
| Only have the request ID and want to take action? Consider using :meth:`JoinRequest.partial`. | ||||||
|
|
||||||
| .. versionadded:: 2.9 | ||||||
|
|
||||||
| Parameters | ||||||
| ---------- | ||||||
| status: Optional[:class:`JoinRequestStatus`] | ||||||
| The single status to which results are restricted. If ``None``, | ||||||
| fetches submitted join requests. | ||||||
|
|
||||||
| Defaults to :data:`None`. | ||||||
| limit: Optional[:class:`int`] | ||||||
| The number of join requests to retrieve. | ||||||
| If ``None``, retrieves every join request, which may be slow. | ||||||
|
|
||||||
| Defaults to ``100``. | ||||||
| before: :class:`.abc.Snowflake` | :class:`datetime.datetime` | None | ||||||
| Retrieves join requests before this date or object. | ||||||
| If a datetime is provided, it is recommended to use a UTC-aware datetime. | ||||||
| If the datetime is naive, it is assumed to be local time. | ||||||
|
|
||||||
| Defaults to :data:`None`. | ||||||
| after: :class:`.abc.Snowflake` | :class:`datetime.datetime` | None | ||||||
| Retrieve join requests after this date or object. | ||||||
| If a datetime is provided, it is recommended to use a UTC-aware datetime. | ||||||
| If the datetime is naive, it is assumed to be local time. | ||||||
|
|
||||||
| Defaults to :data:`None`. | ||||||
|
|
||||||
| Yields | ||||||
| ------ | ||||||
| :class:`JoinRequest` | ||||||
| The join request. | ||||||
|
|
||||||
| Raises | ||||||
| ------ | ||||||
| :exc:`HTTPException` | ||||||
| Retrieving the join requests failed. | ||||||
|
|
||||||
| Examples | ||||||
| -------- | ||||||
|
|
||||||
| Usage :: | ||||||
|
|
||||||
| async for request in guild.join_requests(limit=250): | ||||||
| print(request.user, request.status) | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| Flattening into a list :: | ||||||
|
|
||||||
| requests = await guild.join_requests(limit=None).flatten() | ||||||
| # requests is now a list of JoinRequest... | ||||||
|
|
||||||
| # need the total number of submitted join requests? do this: | ||||||
| iterator = guild.join_requests(limit=None) | ||||||
| await iterator.next() | ||||||
| print(iterator.total) # prints the total number of submitted join requests | ||||||
| requests = await iterator.flatten() | ||||||
| """ | ||||||
| return JoinRequestIterator( | ||||||
| self, | ||||||
| status=status, | ||||||
| limit=limit, | ||||||
| before=before, | ||||||
| after=after, | ||||||
| ) | ||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.