From 9e1ada64b8b8bbc2e8b686f494377f70d3ab8971 Mon Sep 17 00:00:00 2001 From: Fleny Date: Sat, 3 Aug 2024 06:47:26 +0200 Subject: [PATCH] fix(rest): Use a `_` check instead of the manual one on the switch (#3825) * Use a _ check instead of the manual one on the switch * invert the check, as the current one is wrong * move the check to before indexing the object --------- Co-authored-by: Awesome Stickz --- packages/rest/src/manager.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/rest/src/manager.ts b/packages/rest/src/manager.ts index 85dc0c723..a4bd2b1f8 100644 --- a/packages/rest/src/manager.ts +++ b/packages/rest/src/manager.ts @@ -194,6 +194,9 @@ export function createRestManager(options: CreateRestManagerOptions): RestManage const newObj: any = {} for (const key of Object.keys(obj)) { + // If the key is already in snake_case we have no reason for the rest of the code to run. + if (key.includes('_')) continue + const value = obj[key] // Some falsy values should be allowed like null or 0 @@ -204,15 +207,12 @@ export function createRestManager(options: CreateRestManagerOptions): RestManage case 'deny': newObj[key] = typeof value === 'string' ? value : calculateBits(value) continue - case 'default_member_permissions': case 'defaultMemberPermissions': newObj.default_member_permissions = typeof value === 'string' ? value : calculateBits(value) continue - case 'name_localizations': case 'nameLocalizations': newObj.name_localizations = value continue - case 'description_localizations': case 'descriptionLocalizations': newObj.description_localizations = value continue