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 <awesome@stickz.dev>
This commit is contained in:
Fleny
2024-08-03 10:17:26 +05:30
committed by GitHub
co-authored by Awesome Stickz
parent 22a611761b
commit 9e1ada64b8
+3 -3
View File
@@ -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