Currently the /friend commands has a few annoying issues:
Unfriending someone is case sensitive when the target is offline, which is annoying due to players being able to use capital letters for their names, and inconsistent with how friending and unfriending someone work when the target is online. It also tells the player that no online player was found with that name, which is why I received a few reports that you can't remove offline players from the friends list.
Trying to friend someone can result in the removal of another friend if that someone is offline.
Trying to unfriend an offline player can result in the addition of another player. It also doesn't work if the name partially matches the one of the player from another realm.
This is fixed by first checking for friend removal, and allowing it only if their full name is used. Case insensitive. If no friend is removed, IsSameRealm() is called. If it returns false, we simply consider that no player was found, and we don't remove friends even if the name partially matches one in the list.
Then GuessClientByPlayerNameAndRealm()'s result is checked:
If no online player was found (or if they're from another realm), we just leave.
If there's a name collision (no exact match), we leave too.
If there's an exact match (from a non-hostile realm), we add them as a friend (we already checked for friend removal).
If there's a partial match but no name collision, we check against the friends list and prompt the player to use the full name if they wishes to remove them, otherwise we add them as a friend.
Currently the /friend commands has a few annoying issues:
This is fixed by first checking for friend removal, and allowing it only if their full name is used. Case insensitive. If no friend is removed, IsSameRealm() is called. If it returns false, we simply consider that no player was found, and we don't remove friends even if the name partially matches one in the list.
Then GuessClientByPlayerNameAndRealm()'s result is checked: