From f268e1d9798744e169ae87089ea2e1f214364d95 Mon Sep 17 00:00:00 2001 From: Almeida Date: Fri, 17 Feb 2023 19:51:08 +0000 Subject: [PATCH] fix(MessageReaction): `toJSON()` infinite recursion (#9070) * fix(MessageReaction): `toJSON()` infinite recursion * fix: return type Co-authored-by: Jaworek --------- Co-authored-by: Jaworek Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- packages/discord.js/src/structures/MessageReaction.js | 4 ++++ packages/discord.js/typings/index.d.ts | 1 + 2 files changed, 5 insertions(+) diff --git a/packages/discord.js/src/structures/MessageReaction.js b/packages/discord.js/src/structures/MessageReaction.js index d44eb462a..43f05e32b 100644 --- a/packages/discord.js/src/structures/MessageReaction.js +++ b/packages/discord.js/src/structures/MessageReaction.js @@ -117,6 +117,10 @@ class MessageReaction { return flatten(this, { emoji: 'emojiId', message: 'messageId' }); } + valueOf() { + return this._emoji.id ?? this._emoji.name; + } + _add(user) { if (this.partial) return; this.users.cache.set(user.id, user); diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index fd6777177..086b551aa 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -2156,6 +2156,7 @@ export class MessageReaction { public remove(): Promise; public fetch(): Promise; public toJSON(): unknown; + public valueOf(): Snowflake | string; } export interface ModalComponentData {