diff --git a/src/structures/Message.js b/src/structures/Message.js index 2dc8dcc7657a..63046e33f183 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -180,7 +180,14 @@ class Message extends Base { * All valid mentions that the message contains * @type {MessageMentions} */ - this.mentions = new Mentions(this, data.mentions, data.mention_roles, data.mention_everyone, data.mention_channels); + this.mentions = new Mentions( + this, + data.mentions, + data.mention_roles, + data.mention_everyone, + data.mention_channels, + data.referenced_message?.author, + ); /** * ID of the webhook that sent the message, if applicable @@ -314,6 +321,7 @@ class Message extends Base { 'mention_roles' in data ? data.mention_roles : this.mentions.roles, 'mention_everyone' in data ? data.mention_everyone : this.mentions.everyone, 'mention_channels' in data ? data.mention_channels : this.mentions.crosspostedChannels, + 'referenced_message' in data ? data.referenced_message.author : this.mentions.repliedUser, ); this.flags = new MessageFlags('flags' in data ? data.flags : 0).freeze(); diff --git a/src/structures/MessageMentions.js b/src/structures/MessageMentions.js index d4d5fd52a85d..af16eabb42d9 100644 --- a/src/structures/MessageMentions.js +++ b/src/structures/MessageMentions.js @@ -8,7 +8,7 @@ const Util = require('../util/Util'); * Keeps track of mentions in a {@link Message}. */ class MessageMentions { - constructor(message, users, roles, everyone, crosspostedChannels) { + constructor(message, users, roles, everyone, crosspostedChannels, repliedUser) { /** * The client the message is from * @type {Client} @@ -125,6 +125,12 @@ class MessageMentions { } else { this.crosspostedChannels = new Collection(); } + + /** + * The author of the message that this message is a reply to + * @type {?User} + */ + this.repliedUser = repliedUser ? this.client.users.add(repliedUser) : null; } /** diff --git a/typings/index.d.ts b/typings/index.d.ts index 64505d1e9461..fdba348dd473 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -140,6 +140,7 @@ declare module 'discord.js' { APIPartialEmoji as RawEmoji, APIRole as RawRole, Snowflake as APISnowflake, + APIUser, ApplicationCommandOptionType as ApplicationCommandOptionTypes, ApplicationCommandPermissionType as ApplicationCommandPermissionTypes, } from 'discord-api-types/v8'; @@ -1467,9 +1468,10 @@ declare module 'discord.js' { export class MessageMentions { constructor( message: Message, - users: unknown[] | Collection, + users: APIUser[] | Collection, roles: Snowflake[] | Collection, everyone: boolean, + repliedUser?: APIUser | User, ); private _channels: Collection | null; private readonly _content: string; @@ -1481,6 +1483,7 @@ declare module 'discord.js' { public readonly guild: Guild; public has(data: UserResolvable | RoleResolvable | ChannelResolvable, options?: MessageMentionsHasOptions): boolean; public readonly members: Collection | null; + public repliedUser: User | null; public roles: Collection; public users: Collection; public crosspostedChannels: Collection;