diff --git a/packages/discord.js/src/structures/MessageMentions.js b/packages/discord.js/src/structures/MessageMentions.js index b142a6c68..a07e77fb5 100644 --- a/packages/discord.js/src/structures/MessageMentions.js +++ b/packages/discord.js/src/structures/MessageMentions.js @@ -48,6 +48,14 @@ class MessageMentions { */ static GlobalChannelsPattern = new RegExp(this.ChannelsPattern.source, 'g'); + /** + * A global regular expression variant of {@link MessageMentions.UsersPattern}. + * @type {RegExp} + * @memberof MessageMentions + * @private + */ + static GlobalUsersPattern = new RegExp(this.UsersPattern.source, 'g'); + constructor(message, users, roles, everyone, crosspostedChannels, repliedUser) { /** * The client the message is from @@ -225,7 +233,7 @@ class MessageMentions { if (this._parsedUsers) return this._parsedUsers; this._parsedUsers = new Collection(); let matches; - while ((matches = this.constructor.UsersPattern.exec(this._content)) !== null) { + while ((matches = this.constructor.GlobalUsersPattern.exec(this._content)) !== null) { const user = this.client.users.cache.get(matches[1]); if (user) this._parsedUsers.set(user.id, user); } diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index cd8fe8804..617e96c90 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -1881,8 +1881,9 @@ export class MessageMentions { public crosspostedChannels: Collection; public toJSON(): unknown; - public static ChannelsPattern: typeof FormattingPatterns.Channel; private static GlobalChannelsPattern: RegExp; + private static GlobalUsersPattern: RegExp; + public static ChannelsPattern: typeof FormattingPatterns.Channel; public static EveryonePattern: RegExp; public static RolesPattern: typeof FormattingPatterns.Role; public static UsersPattern: typeof FormattingPatterns.User;