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

feat: Guest invites #1062

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

elenakrittik
Copy link
Contributor

@elenakrittik elenakrittik commented Jun 22, 2023

Summary

discord/discord-api-docs#6247

Official Discord client seem to check for whether a member is a guest by asserting not some_member.joined_at, so we'll do the same.

According to docs written by myself invite flags is an optional but not nullable flag. Though if some invite doesn't have flags, it is functionally equivalent to flags = 0, so the flags property is kept out of the Invite's docstring's table.

While not technically being a breaking change (for a reason only Danny and God know Member.joined_at is already optional despite official docs stating that it is always present), this PR actually introduces a real case when it can be optional. I'm not sure whether this should be mentioned in changelog as a breaking change, so decide yourself.

Checklist

  • If code changes were made, then they have been tested
    • I have updated the documentation to reflect the changes
    • I have formatted the code properly by running pdm lint
    • I have type-checked the code by running pdm pyright
  • This PR fixes an issue
  • This PR adds something new (e.g. new method or parameters)
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, ...)

@Victorsitou Victorsitou added t: enhancement New feature t: api support Support of Discord API features s: in progress Issue/PR is being worked on s: waiting for api/docs Issue/PR is waiting for API support/documentation labels Jun 22, 2023
@Victorsitou Victorsitou added this to the disnake v2.10 milestone Jun 22, 2023
@elenakrittik elenakrittik changed the title feat: Guest invites feat!: Guest invites Jun 24, 2023
@elenakrittik elenakrittik changed the title feat!: Guest invites feat: Guest invites Jun 24, 2023
Copy link
Member

@shiftinv shiftinv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
The flags field is also sent in the INVITE_CREATE gateway event and as part of audit logs, those places would need updates as well.

Member.joined_at is already optional despite official docs stating that it is always present

it used to be optional with public stages, which got scrapped a while ago - I wouldn't consider this a breaking change on our end since it's already optional, but it's a breaking change on the API side :>

disnake/member.py Outdated Show resolved Hide resolved
disnake/guild.py Outdated Show resolved Hide resolved
changelog/1062.feature.rst Outdated Show resolved Hide resolved
Copy link
Member

@shiftinv shiftinv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more things I noticed recently.
Also, a more general issue: If all member cache flags are enabled, parse_voice_state_update currently ends up adding the guest to the cache, but does not remove them after leaving. Since the API also doesn't consider guests "real" members of a server, I think it would make sense to just not add them to cache in the first place.

@@ -565,6 +569,14 @@ def url(self) -> str:
url += f"?event={self.guild_scheduled_event.id}"
return url

@property
def flags(self) -> InviteFlags:
""":class:`InviteFlags`: Invite's flags.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
""":class:`InviteFlags`: Invite's flags.
""":class:`InviteFlags`: Returns the invite's flags.

:class:`bool`
Whether the member is a guest.
"""
return self.joined_at is None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also a new member flag, IS_GUEST = 1<<4, which should be more reliable for this. A utility method like this which just returns self.flags.is_guest is still useful, though.

@@ -0,0 +1 @@
Implement Guest invites. See also :attr:`disnake.Invite.flags`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Implement Guest invites. See also :attr:`disnake.Invite.flags`.
Implement Guest invites. See :attr:`Invite.flags` and :attr:`Member.is_guest`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s: in progress Issue/PR is being worked on s: waiting for api/docs Issue/PR is waiting for API support/documentation t: api support Support of Discord API features t: enhancement New feature
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

None yet

3 participants