mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 20:13:30 +01:00
fix: use resolvePartialEmoji on MessagePayload#options#components (#10910)
fix: use resolvePartialEmoji on MessagePayload#components again
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
const { isJSONEncodable } = require('@discordjs/util');
|
const { isJSONEncodable } = require('@discordjs/util');
|
||||||
const snakeCase = require('lodash.snakecase');
|
const snakeCase = require('lodash.snakecase');
|
||||||
|
const { resolvePartialEmoji } = require('./Util');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms camel-cased keys into snake cased keys
|
* Transforms camel-cased keys into snake cased keys
|
||||||
@@ -13,7 +14,14 @@ function toSnakeCase(obj) {
|
|||||||
if (obj instanceof Date) return obj;
|
if (obj instanceof Date) return obj;
|
||||||
if (isJSONEncodable(obj)) return toSnakeCase(obj.toJSON());
|
if (isJSONEncodable(obj)) return toSnakeCase(obj.toJSON());
|
||||||
if (Array.isArray(obj)) return obj.map(toSnakeCase);
|
if (Array.isArray(obj)) return obj.map(toSnakeCase);
|
||||||
return Object.fromEntries(Object.entries(obj).map(([key, value]) => [snakeCase(key), toSnakeCase(value)]));
|
return Object.fromEntries(
|
||||||
|
Object.entries(obj).map(([key, value]) => [
|
||||||
|
snakeCase(key),
|
||||||
|
// TODO: The special handling of 'emoji' is just a temporary fix for v14, will be dropped in v15.
|
||||||
|
// See https://github.com/discordjs/discord.js/issues/10909
|
||||||
|
key === 'emoji' && typeof value === 'string' ? resolvePartialEmoji(value) : toSnakeCase(value),
|
||||||
|
]),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user