PermissionOverwriteManager using a Partial Record

Do you have any intention to remove the use of the Partial<Record<keyof typeof PermissionFlagsBits, boolean | null>> that is declared as PermissionOverwriteOptions in the PermissionOverwriteManager ? There are no enum to replace it yet but that would be cool to have consistency over it as it is for ChannelType, OverwriteType and such.
15 Replies
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Jaworek
Jaworek•2y ago
hm why to remove it?
HunteRoi
HunteRoi•2y ago
Just get rid of the Record<keyof typeof...>, it's a pain in the ass to work with it as it requires either a list of string constants or the use of some shady API to get the string from a property. It would be better to use enums like ChannelType and OverwriteType where you simply have to access a list of flags or a property that returns a bigint. When using the PermissionOverwriteManager, you need to pass it down an object whose properties are string at some point...
Jaworek
Jaworek•2y ago
have u tried PermissonsBitField?
d.js docs
d.js docs•2y ago
class PermissionsBitField (extends BitField) Data structure that makes it easy to interact with a permission bitfield. All GuildMembers have a set of permissions in their guild, and each channel in the guild may also have PermissionOverwrites for the member that override their default permissions.
HunteRoi
HunteRoi•2y ago
PermissionBitField.Flags returns bigint, not strings
Jaworek
Jaworek•2y ago
but it should accept also bitField
HunteRoi
HunteRoi•2y ago
not as a property, computed properties cannot be of type BigInt
d.js docs
d.js docs•2y ago
method PermissionOverwriteManager#edit() Edits permission overwrites for a user or role in this channel, or creates an entry if not already present.
HunteRoi
HunteRoi•2y ago
they must be primitives, like string, number or boolean
HunteRoi
HunteRoi•2y ago
here's a screenshot in case I did not make myself clear in the first place:
Jaworek
Jaworek•2y ago
nah I meant bitfield instead of object but looks like it's not accepting it
HunteRoi
HunteRoi•2y ago
i'd rather use an array of bigints than an object whose properties are strings anyways especially when the only purpose is to specify a list of permissions to include/exclude
Jaworek
Jaworek•2y ago
but it accept bitfields permissionOverweite.upsert(user , { }, {}, {allow: bitfield, deny: bitfield}) or not but as edit not possible but good thing to dogeHaHa
HunteRoi
HunteRoi•2y ago
🆙 any idea if this is being actually considered or should I open an issue on github?