Skip to content

Conversation

Syjalo
Copy link
Contributor

@Syjalo Syjalo commented Jan 28, 2023

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

We don't need BitField#toArray() since we can do Array.from(<BitField>) or [...<BitField>]. Also there was <Collection>.array() which cached values, but the method was removed and not just the caching.

Users use this method to convert bits to human readable strings with a map.

const permissionsMap = {
  'SendMessages': `Send Messages`,
}

They shouldn't use strings for keys, but enums.

const permissionsMap = {
  [PermissionFlagsBits.SendMessages]: `Send Messages`,
}

So the iterator should return an array of bits instead of enum key names.

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
  • This PR changes the library's interface (methods or parameters added)
  • This PR includes breaking changes (methods removed or renamed, parameters moved or removed)

@vercel
Copy link

vercel bot commented Jan 28, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
discord-js ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Jan 28, 2023 at 6:29PM (UTC)

@vercel
Copy link

vercel bot commented Jan 28, 2023

@Syjalo is attempting to deploy a commit to the discordjs Team on Vercel.

A member of the Team first needs to authorize it.

@ImRodry
Copy link
Contributor

ImRodry commented Jan 28, 2023

You don't need a map to convert the strings to a human-readable format, you can simply do that with regex replacement. The toArray() method is also an easy and fast way to read a bitfield without having to do all of those conversions. Please don't merge this.

@vladfrangu
Copy link
Member

I feel like the sentiment for this PR from the two messages speak for themselves. While we'll be closing this PR in its current state, you're free to open a PR that adds a new method that returns only the set bits (for whichever use-case that could have)

@vladfrangu vladfrangu closed this Jul 31, 2024
@Syjalo Syjalo deleted the feat/remove-BitField#toArray() branch August 12, 2024 16:01
@almeidx almeidx removed the blocked label Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants