mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
revert(BitField): ⏪ Bring back-compatibility after BitField serialization (#5910)
This commit is contained in:
@@ -129,9 +129,10 @@ class BitField {
|
||||
/**
|
||||
* Data that can be resolved to give a bitfield. This can be:
|
||||
* * A bit number (this can be a number literal or a value taken from {@link BitField.FLAGS})
|
||||
* * A string bit number
|
||||
* * An instance of BitField
|
||||
* * An Array of BitFieldResolvable
|
||||
* @typedef {number|bigint|BitField|BitFieldResolvable[]} BitFieldResolvable
|
||||
* @typedef {number|string|bigint|BitField|BitFieldResolvable[]} BitFieldResolvable
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -144,7 +145,10 @@ class BitField {
|
||||
if (typeof defaultBit === typeof bit && bit >= defaultBit) return bit;
|
||||
if (bit instanceof BitField) return bit.bitfield;
|
||||
if (Array.isArray(bit)) return bit.map(p => this.resolve(p)).reduce((prev, p) => prev | p, defaultBit);
|
||||
if (typeof bit === 'string' && typeof this.FLAGS[bit] !== 'undefined') return this.FLAGS[bit];
|
||||
if (typeof bit === 'string') {
|
||||
if (typeof this.FLAGS[bit] !== 'undefined') return this.FLAGS[bit];
|
||||
if (!isNaN(bit)) return typeof defaultBit === 'bigint' ? BigInt(bit) : Number(bit);
|
||||
}
|
||||
throw new RangeError('BITFIELD_INVALID', bit);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user