fix(MessagePayload): guard against repliedUser property (#8211)

This commit is contained in:
A. Román
2022-07-03 15:36:32 +02:00
committed by GitHub
parent 6b20645740
commit fa010b5162
3 changed files with 3 additions and 16 deletions

View File

@@ -7,7 +7,7 @@ const ActionRowBuilder = require('./ActionRowBuilder');
const { RangeError, ErrorCodes } = require('../errors'); const { RangeError, ErrorCodes } = require('../errors');
const DataResolver = require('../util/DataResolver'); const DataResolver = require('../util/DataResolver');
const MessageFlagsBitField = require('../util/MessageFlagsBitField'); const MessageFlagsBitField = require('../util/MessageFlagsBitField');
const { basename, cloneObject, verifyString, lazy } = require('../util/Util'); const { basename, verifyString, lazy } = require('../util/Util');
const getBaseInteraction = lazy(() => require('./BaseInteraction')); const getBaseInteraction = lazy(() => require('./BaseInteraction'));
@@ -165,9 +165,8 @@ class MessagePayload {
? this.target.client.options.allowedMentions ? this.target.client.options.allowedMentions
: this.options.allowedMentions; : this.options.allowedMentions;
if (allowedMentions) { if (typeof allowedMentions?.repliedUser !== 'undefined') {
allowedMentions = cloneObject(allowedMentions); allowedMentions = { ...allowedMentions, replied_user: allowedMentions.repliedUser };
allowedMentions.replied_user = allowedMentions.repliedUser;
delete allowedMentions.repliedUser; delete allowedMentions.repliedUser;
} }

View File

@@ -266,16 +266,6 @@ function resolvePartialEmoji(emoji) {
return { id, name, animated: Boolean(animated) }; return { id, name, animated: Boolean(animated) };
} }
/**
* Shallow-copies an object with its class/prototype intact.
* @param {Object} obj Object to clone
* @returns {Object}
* @private
*/
function cloneObject(obj) {
return Object.assign(Object.create(obj), obj);
}
/** /**
* Sets default properties on an object that aren't already specified. * Sets default properties on an object that aren't already specified.
* @param {Object} def Default properties * @param {Object} def Default properties
@@ -568,7 +558,6 @@ module.exports = {
fetchRecommendedShards, fetchRecommendedShards,
parseEmoji, parseEmoji,
resolvePartialEmoji, resolvePartialEmoji,
cloneObject,
mergeDefault, mergeDefault,
makeError, makeError,
makePlainError, makePlainError,

View File

@@ -2628,7 +2628,6 @@ export class UserFlagsBitField extends BitField<UserFlagsString> {
export function basename(path: string, ext?: string): string; export function basename(path: string, ext?: string): string;
export function cleanContent(str: string, channel: TextBasedChannel): string; export function cleanContent(str: string, channel: TextBasedChannel): string;
export function cloneObject(obj: unknown): unknown;
export function discordSort<K, V extends { rawPosition: number; id: Snowflake }>( export function discordSort<K, V extends { rawPosition: number; id: Snowflake }>(
collection: Collection<K, V>, collection: Collection<K, V>,
): Collection<K, V>; ): Collection<K, V>;