diff --git a/src/util/Util.js b/src/util/Util.js index 47ceef45b73e..f7d5487f51e3 100644 --- a/src/util/Util.js +++ b/src/util/Util.js @@ -538,6 +538,10 @@ class Util extends null { deprecationEmittedForRemoveMentions = true; } + return Util._removeMentions(str); + } + + static _removeMentions(str) { return str.replaceAll('@', '@\u200b'); } @@ -555,15 +559,15 @@ class Util extends null { const id = input.replace(/<|!|>|@/g, ''); if (channel.type === 'DM') { const user = channel.client.users.cache.get(id); - return user ? Util.removeMentions(`@${user.username}`) : input; + return user ? Util._removeMentions(`@${user.username}`) : input; } const member = channel.guild.members.cache.get(id); if (member) { - return Util.removeMentions(`@${member.displayName}`); + return Util._removeMentions(`@${member.displayName}`); } else { const user = channel.client.users.cache.get(id); - return user ? Util.removeMentions(`@${user.username}`) : input; + return user ? Util._removeMentions(`@${user.username}`) : input; } }) .replace(/<#[0-9]+>/g, input => { diff --git a/typings/index.d.ts b/typings/index.d.ts index 0206ffd7dd7d..0dd89f258116 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -2416,6 +2416,7 @@ export class Util extends null { public static cleanContent(str: string, channel: TextBasedChannel): string; /** @deprecated Use {@link MessageOptions.allowedMentions} to control mentions in a message instead. */ public static removeMentions(str: string): string; + private static _removeMentions(str: string): string; public static cloneObject(obj: unknown): unknown; public static discordSort( collection: Collection,