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
* @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

12
typings/index.d.ts vendored
View File

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