-
Notifications
You must be signed in to change notification settings - Fork 138
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
base: master
Are you sure you want to change the base?
feat: Guest invites #1062
Conversation
There was a problem hiding this 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 :>
Co-authored-by: shiftinv <8530778+shiftinv@users.noreply.github.com> Signed-off-by: lena <77104725+elenakrittik@users.noreply.github.com>
There was a problem hiding this 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
""":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 |
There was a problem hiding this comment.
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`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implement Guest invites. See also :attr:`disnake.Invite.flags`. | |
Implement Guest invites. See :attr:`Invite.flags` and :attr:`Member.is_guest`. |
Summary
discord/discord-api-docs#6247
Official Discord client seem to check for whether a member is a guest by
assert
ingnot some_member.joined_at
, so we'll do the same.According to docs
written by myselfinvite flags is an optional but not nullable flag. Though if some invite doesn't have flags, it is functionally equivalent toflags = 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
pdm lint
pdm pyright