fix(rest)!: Remove calculateBits from changeToDiscordFormat (#4557)

* fix(rest)!: Remove calculateBits from changeToDiscordFormat

The rest manager currently has to assume that request bodies that have "permissions", "allow", "deny", "defaultMemberPermissions" fields are always meant as a permissions.
If these are not, for user error or future discord changes, this will break.

Also Discord expects these as strings, and discordeno does not abstract too much from the discord api, so it doesn't really makes sense for us to accept PermissionStrings[], the user should call calculateBits themselves, there is an argument to be made about accepting bigints since these are bitfields but that's another discussion.

* Channel.permissionOverwrites use PermissionStrings

For the transformed type we can keep the fact that it uses PermissionStrings

* Fix e2e test

* remove comment
This commit is contained in:
Fleny
2026-01-27 18:46:19 +01:00
committed by GitHub
parent 9085f4a454
commit 4eccbea89f
6 changed files with 20 additions and 25 deletions
-10
View File
@@ -59,7 +59,6 @@ import type {
ModifyGuildTemplate,
} from '@discordeno/types';
import {
calculateBits,
camelize,
camelToSnakeCase,
DISCORDENO_VERSION,
@@ -236,17 +235,8 @@ export function createRestManager(options: CreateRestManagerOptions): RestManage
continue;
}
// Some falsy values should be allowed like null or 0
if (value !== undefined) {
switch (key) {
case 'permissions':
case 'allow':
case 'deny':
newObj[key] = typeof value === 'string' ? value : calculateBits(value);
continue;
case 'defaultMemberPermissions':
newObj.default_member_permissions = typeof value === 'string' ? value : calculateBits(value);
continue;
case 'nameLocalizations':
newObj.name_localizations = value;
continue;