Skip to content

Commit

Permalink
Deprecate Member::distinct (serenity-rs#3083)
Browse files Browse the repository at this point in the history
The method is just wrong. Only the username is accompanied by the
discriminator, not the global name or nickname, so this method only adds
confusion.
  • Loading branch information
jamesbt365 authored Dec 12, 2024
1 parent 8437326 commit 452bf82
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/model/guild/member.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ impl Member {
/// Returns the DiscordTag of a Member, taking possible nickname into account.
#[inline]
#[must_use]
#[deprecated = "Use User::tag to get the correct Discord username format or Self::display_name for the name that users will see."]
pub fn distinct(&self) -> String {
if let Some(discriminator) = self.user.discriminator {
format!("{}#{:04}", self.display_name(), discriminator.get())
Expand Down
4 changes: 3 additions & 1 deletion src/utils/content_safe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ fn clean_mention(
if let Some(guild) = cache.guild(guild_id) {
if let Some(member) = guild.members.get(&id) {
return if options.show_discriminator {
format!("@{}", member.distinct())
#[allow(deprecated)]
let name = member.distinct();
format!("@{name}")
} else {
format!("@{}", member.display_name())
}
Expand Down

0 comments on commit 452bf82

Please sign in to comment.