Convert username mentions even if nickname set #208
Merged
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.
In Discord, using
@username
pings the person with the username even if they currently have their nickname set to something else. As nicknames can have non-ASCII characters in them (or rather, characters that constitute a 'boundary' per the/@[^\s]+\b/g
regex to match @-mentions of usernames), and usernames don't tend to (or perhaps can't), enabling username mentions even when a nickname is set would allow IRC users to still mention users with such nicknames.I can't immediately think of a use-case where this distinction would be useful (or expected), and as Discord itself handles it differently I don't think this is the correct behavior.
In addition, I think the test for this behavior (not creating a mention if nickname differs from username) was broken. See where
'Hello, @username!'
becomes'Hello, @testuser!'
below – it wasn't in fact referencing an existent user, so this was instead testing that mentioning a nonexistent user doesn't change the mention text.