fix(GuildAuditLogsEntry): correct mapped AuditLogChange objects

backport #10438 djs v14
This commit is contained in:
Elysia
2024-09-17 10:09:22 +07:00
parent e7ff84471c
commit 37e52486ff
2 changed files with 13 additions and 6 deletions

View File

@@ -457,7 +457,12 @@ class GuildAuditLogsEntry {
* Specific property changes * Specific property changes
* @type {AuditLogChange[]} * @type {AuditLogChange[]}
*/ */
this.changes = data.changes?.map(c => ({ key: c.key, old: c.old_value, new: c.new_value })) ?? []; this.changes =
data.changes?.map(change => ({
key: change.key,
...('old_value' in change ? { old: change.old_value } : {}),
...('new_value' in change ? { new: change.new_value } : {}),
})) ?? [];
/** /**
* The entry's id * The entry's id

12
typings/index.d.ts vendored
View File

@@ -5197,11 +5197,13 @@ export interface AutoModerationActionMetadataOptions extends Partial<Omit<AutoMo
channel: GuildTextChannelResolvable | ThreadChannel; channel: GuildTextChannelResolvable | ThreadChannel;
} }
export interface AuditLogChange { export type AuditLogChange = {
key: APIAuditLogChange['key']; [SourceElement in APIAuditLogChange as SourceElement['key']]: {
old?: APIAuditLogChange['old_value']; key: SourceElement['key'];
new?: APIAuditLogChange['new_value']; old?: SourceElement['old_value'];
} new?: SourceElement['new_value'];
};
}[APIAuditLogChange['key']];
export type Awaitable<T> = T | PromiseLike<T>; export type Awaitable<T> = T | PromiseLike<T>;