Skip to content

Commit f2f757c

Browse files
authored
fix: use resolvePartialEmoji on MessagePayload#options#components (#10910)
fix: use resolvePartialEmoji on MessagePayload#components again
1 parent 65cfa3f commit f2f757c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/discord.js/src/util/Transformers.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const { isJSONEncodable } = require('@discordjs/util');
44
const 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
/**

0 commit comments

Comments
 (0)