-
-
Notifications
You must be signed in to change notification settings - Fork 6
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: command permissions #212
Conversation
🦋 Changeset detectedLatest commit: fe259e4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
b2d91e9
to
268b88d
Compare
* The default permission that a user needs to have to use this command. | ||
* This can be overridden by server admins. | ||
*/ | ||
permission?: (typeof Permission)[keyof typeof Permission] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type resolves to just bigint
anyway (so can use bit manipulation), but is any reason this isn't an array that can later be resolved to a bigint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still not sure how I feel about this but I think it's the best way.
Permission
reexports the enum PermissionFlagBits from discord-api-types
, which is the only spot all permissions are defined.
The alternative that we could do is maintain our own list, separate from discord-api-types
.
I was trying at one point to type it as keyof typeof Permission
so that users would just pass "ManageGuild", etc, but it was being typed as a string and not const so that wasn't working cleanly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While keyof typeof Permission
seems to work as expected for me, I was more referring to just
permissions?: ((typeof Permission)[keyof typeof Permission])[]
and then later use reduce in the serialize method to combine those bits
this.permissions ? this.permissions.reduce((a, p) => a | p, 0n).toString() : null
a8d44f8
to
fe259e4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer a plural for the property name to match the docs but if you prefer as is that is fine
Closes #155