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

Remove case of bang (!) from Member.mention property #1207

Merged
merged 4 commits into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/1207.breaking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removed case of `Member.mention` returning bang (`!`) mention, as it is deprecated by Discord.
23 changes: 1 addition & 22 deletions hikari/guilds.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,28 +484,7 @@ def is_system(self) -> bool:

@property
def mention(self) -> str:
"""Return a raw mention string for the given member.

If the member has a known nickname, we always return
a bang ("`!`") before the ID part of the mention string. This
mimics the behaviour Discord clients tend to provide.

Example
-------

```py
>>> some_member_without_nickname.mention
'<@123456789123456789>'
>>> some_member_with_nickname.mention
'<@!123456789123456789>'
```

Returns
-------
builtins.str
The mention string to use.
"""
return f"<@!{self.id}>" if self.nickname is not None else self.user.mention
return self.user.mention
GoogolGenius marked this conversation as resolved.
Show resolved Hide resolved

def communication_disabled_until(self) -> typing.Optional[datetime.datetime]:
"""Return when the timeout for this member ends.
Expand Down
6 changes: 1 addition & 5 deletions tests/hikari/test_guilds.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,11 +485,7 @@ def test_display_name_property_when_no_nickname(self, model, mock_user):
model.nickname = None
assert model.display_name is mock_user.username

def test_mention_property_when_nickname(self, model):
assert model.mention == "<@!123>"

def test_mention_property_when_no_nickname(self, model, mock_user):
model.nickname = None
def test_mention_property(self, model, mock_user):
assert model.mention == mock_user.mention

def test_get_guild(self, model):
Expand Down