File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
packages/discord.js/src/util Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 22
33const { isJSONEncodable } = require ( '@discordjs/util' ) ;
44const snakeCase = require ( 'lodash.snakecase' ) ;
5+ const { resolvePartialEmoji } = require ( './Util' ) ;
56
67/**
78 * Transforms camel-cased keys into snake cased keys
@@ -13,7 +14,14 @@ function toSnakeCase(obj) {
1314 if ( obj instanceof Date ) return obj ;
1415 if ( isJSONEncodable ( obj ) ) return toSnakeCase ( obj . toJSON ( ) ) ;
1516 if ( Array . isArray ( obj ) ) return obj . map ( toSnakeCase ) ;
16- return Object . fromEntries ( Object . entries ( obj ) . map ( ( [ key , value ] ) => [ snakeCase ( key ) , toSnakeCase ( value ) ] ) ) ;
17+ return Object . fromEntries (
18+ Object . entries ( obj ) . map ( ( [ key , value ] ) => [
19+ snakeCase ( key ) ,
20+ // TODO: The special handling of 'emoji' is just a temporary fix for v14, will be dropped in v15.
21+ // See https://github.com/discordjs/discord.js/issues/10909
22+ key === 'emoji' && typeof value === 'string' ? resolvePartialEmoji ( value ) : toSnakeCase ( value ) ,
23+ ] ) ,
24+ ) ;
1725}
1826
1927/**
You can’t perform that action at this time.
0 commit comments