From b6ddd4ce413663aef6f4ea637f2551f5e19bdf6e Mon Sep 17 00:00:00 2001 From: Sugden <28943913+NotSugden@users.noreply.github.com> Date: Wed, 12 Aug 2020 20:25:38 +0100 Subject: [PATCH] fix(APIMessage): add reply user to allowedMentions (#4591) --- src/structures/APIMessage.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/structures/APIMessage.js b/src/structures/APIMessage.js index a3c44a4e7..673db0390 100644 --- a/src/structures/APIMessage.js +++ b/src/structures/APIMessage.js @@ -178,10 +178,25 @@ class APIMessage { flags = this.options.flags != null ? new MessageFlags(this.options.flags).bitfield : this.target.flags.bitfield; } - const allowedMentions = + let allowedMentions = typeof this.options.allowedMentions === 'undefined' ? this.target.client.options.allowedMentions : this.options.allowedMentions; + if (this.options.reply) { + const id = this.target.client.users.resolveID(this.options.reply); + if (allowedMentions) { + // Clone the object as to alter the ClientOptions object + allowedMentions = Util.cloneObject(allowedMentions); + const parsed = allowedMentions.parse && allowedMentions.parse.includes('users'); + // Check if the mention won't be parsed, and isn't supplied in `users` + if (!parsed && !(allowedMentions.users && allowedMentions.users.includes(id))) { + if (!allowedMentions.users) allowedMentions.users = []; + allowedMentions.users.push(id); + } + } else { + allowedMentions = { users: [id] }; + } + } this.data = { content,