Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert(BitField): ⏪ Bring back-compatibility after BitField serialization #5910

Merged
merged 3 commits into from
Jun 28, 2021

Conversation

DraftProducts
Copy link
Contributor

Please describe the changes this PR makes and why it should be merged:

In #4879, some modifications were made to permissions and bitfield methods.
Especially on the type of bitfields that moves from number to BigInt.

This move has some impact on serialization and deserialization.
Take the example of a simple JSON.stringify and JSON.parse.
The method toJSON() (provided by BitField class) will be called and the type (BigInt in the case of Permissions) will be transformed into a string:

8n => "8"

In the past, this type changing was not needed because a number remains a number.
In the actual Bitfield class if you try to pass permissions that went through serialization and deserialization you get the beautiful error BITFIELD_INVALID.
So a simple role or channel creation bring you to a crash of your action.

This PR is here to provide compatibility between Bigint stringified and BitFields.

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating

src/util/BitField.js Outdated Show resolved Hide resolved
typings/index.d.ts Outdated Show resolved Hide resolved
@iCrawl iCrawl added this to the Version 13 milestone Jun 27, 2021
@iCrawl iCrawl merged commit 0a0630c into discordjs:master Jun 28, 2021
@DraftProducts DraftProducts deleted the feature-bitfield branch June 28, 2021 14:42
iCrawl added a commit to amishshah/discord.js that referenced this pull request Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants