feat(MessageMentions): add repliedUser (#5905)

This commit is contained in:
Jan
2021-06-25 12:07:31 +02:00
committed by GitHub
parent 5af2ef5fbc
commit 261612596d
3 changed files with 20 additions and 3 deletions

View File

@@ -190,7 +190,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
@@ -325,6 +332,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();

View File

@@ -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;
}
/**