File tree Expand file tree Collapse file tree 3 files changed +23
-6
lines changed Expand file tree Collapse file tree 3 files changed +23
-6
lines changed Original file line number Diff line number Diff line change @@ -172,7 +172,11 @@ class GuildAuditLogsEntry {
172
172
* @type {AuditLogChange[] }
173
173
*/
174
174
this . changes =
175
- data . changes ?. map ( change => ( { key : change . key , old : change . old_value , new : change . new_value } ) ) ?? [ ] ;
175
+ data . changes ?. map ( change => ( {
176
+ key : change . key ,
177
+ ...( 'old_value' in change ? { old : change . old_value } : { } ) ,
178
+ ...( 'new_value' in change ? { new : change . new_value } : { } ) ,
179
+ } ) ) ?? [ ] ;
176
180
177
181
/**
178
182
* The entry's id
Original file line number Diff line number Diff line change @@ -4991,11 +4991,13 @@ export interface ApplicationRoleConnectionMetadataEditOptions {
4991
4991
type : ApplicationRoleConnectionMetadataType ;
4992
4992
}
4993
4993
4994
- export interface AuditLogChange {
4995
- key : APIAuditLogChange [ 'key' ] ;
4996
- old ?: APIAuditLogChange [ 'old_value' ] ;
4997
- new ?: APIAuditLogChange [ 'new_value' ] ;
4998
- }
4994
+ export type AuditLogChange = {
4995
+ [ SourceElement in APIAuditLogChange as SourceElement [ 'key' ] ] : {
4996
+ key : SourceElement [ 'key' ] ;
4997
+ old ?: SourceElement [ 'old_value' ] ;
4998
+ new ?: SourceElement [ 'new_value' ] ;
4999
+ } ;
5000
+ } [ APIAuditLogChange [ 'key' ] ] ;
4999
5001
5000
5002
export interface AutoModerationAction {
5001
5003
type : AutoModerationActionType ;
Original file line number Diff line number Diff line change @@ -104,6 +104,7 @@ import {
104
104
Collector ,
105
105
GuildAuditLogsEntry ,
106
106
GuildAuditLogs ,
107
+ type AuditLogChange ,
107
108
StageInstance ,
108
109
ActionRowBuilder ,
109
110
ButtonComponent ,
@@ -2171,6 +2172,16 @@ expectType<Promise<User | undefined>>(
2171
2172
guild . fetchAuditLogs ( { type : AuditLogEvent . MessageDelete } ) . then ( al => al . entries . first ( ) ?. target ) ,
2172
2173
) ;
2173
2174
2175
+ declare const AuditLogChange : AuditLogChange ;
2176
+ // @ts -expect-error
2177
+ expectType < boolean | undefined > ( AuditLogChange . old ) ;
2178
+ // @ts -expect-error
2179
+ expectType < boolean | undefined > ( AuditLogChange . new ) ;
2180
+ if ( AuditLogChange . key === 'available' ) {
2181
+ expectType < boolean | undefined > ( AuditLogChange . old ) ;
2182
+ expectType < boolean | undefined > ( AuditLogChange . new ) ;
2183
+ }
2184
+
2174
2185
declare const TextBasedChannel : TextBasedChannel ;
2175
2186
declare const TextBasedChannelTypes : TextBasedChannelTypes ;
2176
2187
declare const VoiceBasedChannel : VoiceBasedChannel ;
You can’t perform that action at this time.
0 commit comments