Skip to content

Commit 45fb401

Browse files
committed
Remove ContentSafeOptions::show_discriminator
1 parent 5f07257 commit 45fb401

File tree

1 file changed

+4
-27
lines changed

1 file changed

+4
-27
lines changed

src/utils/content_safe.rs

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,6 @@ pub struct ContentSafeOptions {
2929
pub clean_here: bool,
3030
/// If set, [`content_safe`] will replace `@everyone` with a non-pinging alternative.
3131
pub clean_everyone: bool,
32-
/// If set to true, if [`content_safe`] replaces a user mention it will add their four digit
33-
/// discriminator with a preceding `#`, turning `@username` to `@username#discriminator`.
34-
///
35-
/// This option is ignored if the username is a next-gen username, and
36-
/// therefore does not have a discriminator.
37-
#[cfg_attr(not(ignore_serenity_deprecated), deprecated = "Discriminators are deprecated on the discord side, and this doesn't reflect message rendering behaviour")]
38-
pub show_discriminator: bool,
3932
}
4033

4134
impl ContentSafeOptions {
@@ -140,7 +133,7 @@ fn clean_mentions(guild: &Guild, s: &str, options: ContentSafeOptions, users: &[
140133
// NOTE: numeric strings that are too large to fit into u64 will not parse
141134
// correctly and will be left unchanged.
142135
if let Ok(mention) = mention_str.parse() {
143-
content.push_str(&clean_mention(guild, mention, options, users));
136+
content.push_str(&clean_mention(guild, mention, users));
144137
cleaned = true;
145138
}
146139
}
@@ -156,12 +149,7 @@ fn clean_mentions(guild: &Guild, s: &str, options: ContentSafeOptions, users: &[
156149
content
157150
}
158151

159-
fn clean_mention(
160-
guild: &Guild,
161-
mention: Mention,
162-
options: ContentSafeOptions,
163-
users: &[User],
164-
) -> Cow<'static, str> {
152+
fn clean_mention(guild: &Guild, mention: Mention, users: &[User]) -> Cow<'static, str> {
165153
match mention {
166154
Mention::Channel(id) => {
167155
if let Some(channel) = guild.channels.get(&id) {
@@ -176,19 +164,9 @@ fn clean_mention(
176164
.map_or(Cow::Borrowed("@deleted-role"), |role| format!("@{}", role.name).into()),
177165
Mention::User(id) => {
178166
if let Some(member) = guild.members.get(&id) {
179-
if options.get_show_discriminator() {
180-
#[expect(deprecated)]
181-
let name = member.distinct();
182-
format!("@{name}").into()
183-
} else {
184-
format!("@{}", member.display_name()).into()
185-
}
167+
format!("@{}", member.display_name()).into()
186168
} else if let Some(user) = users.iter().find(|u| u.id == id) {
187-
if options.get_show_discriminator() {
188-
format!("@{}", user.tag()).into()
189-
} else {
190-
format!("@{}", user.name).into()
191-
}
169+
format!("@{}", user.name).into()
192170
} else {
193171
"@invalid-user".into()
194172
}
@@ -265,7 +243,6 @@ mod tests {
265243
);
266244

267245
let mut options = ContentSafeOptions::default();
268-
options = options.show_discriminator(false);
269246
assert_eq!(
270247
format!("@{}", user.name),
271248
content_safe(&no_member_guild, "<@!100000000000000000>", options, &[user.clone()])

0 commit comments

Comments
 (0)