dfx icon indicating copy to clipboard operation
dfx copied to clipboard

Suggestion: Discord permission bitfield type should be either `string` or `bigint` consistently instead of `number`

Open bgenia opened this issue 7 months ago • 3 comments

Currently discord rest types such as UpdateGuildRoleRequest and ApplicationCommandUpdateRequest use number type for permissions while some others (like ApplicationCommandResponse) use string. AFAIK discord API itself uses strings for permissions and dfx Perms helper uses bigint, so number is really inconvenient here. I suggest using either string or bigint consistently instead.

bgenia avatar Jun 12 '25 10:06 bgenia

dfx doesn't modify the rest responses to keep the maintenance burden low. I think most of the permission helpers accept string or bigint.

tim-smart avatar Jun 15 '25 07:06 tim-smart

dfx doesn't modify the rest responses to keep the maintenance burden low

Then I suggest adding permission helpers for number type.

Example:

Ix.guild({
  // 'bigint' is not assignable to type 'number' => unsafe manual cast required
  default_member_permissions: Perms.fromList(["Administrator"])
})

bgenia avatar Jun 15 '25 16:06 bgenia

In that case you would just do Number(Perms.fromList(["Administrator"])), I don't think that is too bad.

tim-smart avatar Jun 15 '25 21:06 tim-smart