mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 11:03:30 +01:00
fix: unsafe embed builder field normalization (#7418)
This commit is contained in:
14
packages/builders/src/util/jsonEncodable.ts
Normal file
14
packages/builders/src/util/jsonEncodable.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
export interface JSONEncodable<T> {
|
||||
/**
|
||||
* Transforms this object to its JSON format
|
||||
*/
|
||||
toJSON: () => T;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if an object is encodable or not.
|
||||
* @param maybeEncodable The object to check against
|
||||
*/
|
||||
export function isJSONEncodable(maybeEncodable: unknown): maybeEncodable is JSONEncodable<unknown> {
|
||||
return maybeEncodable !== null && typeof maybeEncodable === 'object' && 'toJSON' in maybeEncodable;
|
||||
}
|
||||
Reference in New Issue
Block a user