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

feat(Permissions): Add new method Permissions#any #3450

Merged
merged 5 commits into from Sep 10, 2019

Conversation

@Monbrey
Copy link
Contributor

commented Aug 27, 2019

From you never knew#0717 in d.js support who had the idea for this method.
It does what Permissions#has does (its basically a copypasta of it), but will return true if any of the Permissions provided exist, rather than all of them.

I'm not sure how common the use-case will be, but here it is for consideration.

Status

  • 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

Semantic versioning classification:

  • This PR changes the library's interface (methods or parameters added)
    • This PR includes breaking changes (methods removed or renamed, parameters moved or removed)
  • This PR only includes non-code changes, like changes to documentation, README, etc.
@Fyko
Fyko approved these changes Aug 27, 2019
@ShayBox

This comment has been minimized.

Copy link
Contributor

commented Aug 27, 2019

LGTM 👍

@iCrawl
iCrawl approved these changes Sep 3, 2019
@bdistin

This comment has been minimized.

Copy link
Member

commented Sep 3, 2019

This will not work as you expect it to when passing Permission instances, numbers with more than one bit, etc.

Consider new Permissions(19456).any(2100224)
19456 = 0x400 | 0x800 | 0x4000
2100224 = 0x400 | 0x800 | 0x200000
19456 & 2100224 !== 2100224

But, 19456 does include 0x400 and 0x800...

src/util/BitField.js Outdated Show resolved Hide resolved
src/util/Permissions.js Outdated Show resolved Hide resolved
src/util/Permissions.js Outdated Show resolved Hide resolved
@bdistin
bdistin approved these changes Sep 8, 2019

@SpaceEEC SpaceEEC force-pushed the Monbrey:permissions-any branch from 7a5f1fb to 60dc981 Sep 10, 2019

@SpaceEEC SpaceEEC merged commit a6810e2 into discordjs:master Sep 10, 2019

3 checks passed

ESLint
Details
TSLint
Details
Documentation
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.