Skip to content

Commit

Permalink
Merge pull request #3 from alluding/patch-2
Browse files Browse the repository at this point in the history
update `position`
  • Loading branch information
cop-discord authored Apr 11, 2024
2 parents 2b7bf41 + dce1d2a commit 34a7277
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions discord/member.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,20 @@ def raw_status(self) -> str:

@property
def position(self) -> int:
""" Integer: the member's join position in the guild """
return sorted(self.guild.members,key=lambda x: x.joined_at).index(self)+1
"""Returns the join position of the member in the guild.
If the member's join position cannot be determined (e.g., if the member is not part
of any guild), it returns 0.
Returns:
int: The join position of the member in the guild.
"""
guild: Guild | None = getattr(self, "guild", None)
return (
0
if not guild
else sum(m.joined_at < self.joined_at for m in guild.members) + 1
)

@status.setter
def status(self, value: Status) -> None:
Expand Down

0 comments on commit 34a7277

Please sign in to comment.