From 40d07fbbbd51d62793d9ea541f41f157b5dad224 Mon Sep 17 00:00:00 2001 From: Jaw0r3k Date: Fri, 28 Apr 2023 19:25:11 +0200 Subject: [PATCH] fix(BitField): use only enum names in iterating (#9357) * fix: use only names in iterating bitfield * fix: not a number Co-authored-by: Vlad Frangu * fix: serialize Co-authored-by: SpaceEEC --------- Co-authored-by: Vlad Frangu Co-authored-by: SpaceEEC Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- packages/discord.js/src/util/BitField.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/discord.js/src/util/BitField.js b/packages/discord.js/src/util/BitField.js index 80e68ed399eb..f0778f68807a 100644 --- a/packages/discord.js/src/util/BitField.js +++ b/packages/discord.js/src/util/BitField.js @@ -117,7 +117,9 @@ class BitField { */ serialize(...hasParams) { const serialized = {}; - for (const [flag, bit] of Object.entries(this.constructor.Flags)) serialized[flag] = this.has(bit, ...hasParams); + for (const [flag, bit] of Object.entries(this.constructor.Flags)) { + if (isNaN(flag)) serialized[flag] = this.has(bit, ...hasParams); + } return serialized; } @@ -140,7 +142,7 @@ class BitField { *[Symbol.iterator](...hasParams) { for (const bitName of Object.keys(this.constructor.Flags)) { - if (this.has(bitName, ...hasParams)) yield bitName; + if (isNaN(bitName) && this.has(bitName, ...hasParams)) yield bitName; } }