Skip to content

Commit

Permalink
fix(MessagePayload): guard against repliedUser property (#8211)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranet committed Jul 3, 2022
1 parent 6b20645 commit fa010b5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 16 deletions.
7 changes: 3 additions & 4 deletions packages/discord.js/src/structures/MessagePayload.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const ActionRowBuilder = require('./ActionRowBuilder');
const { RangeError, ErrorCodes } = require('../errors');
const DataResolver = require('../util/DataResolver');
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'));

Expand Down Expand Up @@ -165,9 +165,8 @@ class MessagePayload {
? this.target.client.options.allowedMentions
: this.options.allowedMentions;

if (allowedMentions) {
allowedMentions = cloneObject(allowedMentions);
allowedMentions.replied_user = allowedMentions.repliedUser;
if (typeof allowedMentions?.repliedUser !== 'undefined') {
allowedMentions = { ...allowedMentions, replied_user: allowedMentions.repliedUser };
delete allowedMentions.repliedUser;
}

Expand Down
11 changes: 0 additions & 11 deletions packages/discord.js/src/util/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,16 +266,6 @@ function resolvePartialEmoji(emoji) {
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.
* @param {Object} def Default properties
Expand Down Expand Up @@ -568,7 +558,6 @@ module.exports = {
fetchRecommendedShards,
parseEmoji,
resolvePartialEmoji,
cloneObject,
mergeDefault,
makeError,
makePlainError,
Expand Down
1 change: 0 additions & 1 deletion packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2628,7 +2628,6 @@ export class UserFlagsBitField extends BitField<UserFlagsString> {

export function basename(path: string, ext?: string): 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 }>(
collection: Collection<K, V>,
): Collection<K, V>;
Expand Down

0 comments on commit fa010b5

Please sign in to comment.