mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 03:23:29 +01:00
fix(MessageMentions): infinite loop in parsedUsers getter (#8430)
This commit is contained in:
@@ -48,6 +48,14 @@ class MessageMentions {
|
|||||||
*/
|
*/
|
||||||
static GlobalChannelsPattern = new RegExp(this.ChannelsPattern.source, 'g');
|
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) {
|
constructor(message, users, roles, everyone, crosspostedChannels, repliedUser) {
|
||||||
/**
|
/**
|
||||||
* The client the message is from
|
* The client the message is from
|
||||||
@@ -225,7 +233,7 @@ class MessageMentions {
|
|||||||
if (this._parsedUsers) return this._parsedUsers;
|
if (this._parsedUsers) return this._parsedUsers;
|
||||||
this._parsedUsers = new Collection();
|
this._parsedUsers = new Collection();
|
||||||
let matches;
|
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]);
|
const user = this.client.users.cache.get(matches[1]);
|
||||||
if (user) this._parsedUsers.set(user.id, user);
|
if (user) this._parsedUsers.set(user.id, user);
|
||||||
}
|
}
|
||||||
|
|||||||
3
packages/discord.js/typings/index.d.ts
vendored
3
packages/discord.js/typings/index.d.ts
vendored
@@ -1881,8 +1881,9 @@ export class MessageMentions {
|
|||||||
public crosspostedChannels: Collection<Snowflake, CrosspostedChannel>;
|
public crosspostedChannels: Collection<Snowflake, CrosspostedChannel>;
|
||||||
public toJSON(): unknown;
|
public toJSON(): unknown;
|
||||||
|
|
||||||
public static ChannelsPattern: typeof FormattingPatterns.Channel;
|
|
||||||
private static GlobalChannelsPattern: RegExp;
|
private static GlobalChannelsPattern: RegExp;
|
||||||
|
private static GlobalUsersPattern: RegExp;
|
||||||
|
public static ChannelsPattern: typeof FormattingPatterns.Channel;
|
||||||
public static EveryonePattern: RegExp;
|
public static EveryonePattern: RegExp;
|
||||||
public static RolesPattern: typeof FormattingPatterns.Role;
|
public static RolesPattern: typeof FormattingPatterns.Role;
|
||||||
public static UsersPattern: typeof FormattingPatterns.User;
|
public static UsersPattern: typeof FormattingPatterns.User;
|
||||||
|
|||||||
Reference in New Issue
Block a user