@@ -775,7 +775,8 @@ class Guild extends AnonymousGuild {
775
775
/**
776
776
* Options used to fetch audit logs.
777
777
* @typedef {Object } GuildAuditLogsFetchOptions
778
- * @property {Snowflake|GuildAuditLogsEntry } [before] Only return entries before this entry
778
+ * @property {Snowflake|GuildAuditLogsEntry } [before] Consider only entries before this entry
779
+ * @property {Snowflake|GuildAuditLogsEntry } [after] Consider only entries after this entry
779
780
* @property {number } [limit] The number of entries to return
780
781
* @property {UserResolvable } [user] Only return entries for actions made by this user
781
782
* @property {AuditLogAction|number } [type] Only return entries for this action type
@@ -791,18 +792,17 @@ class Guild extends AnonymousGuild {
791
792
* .then(audit => console.log(audit.entries.first()))
792
793
* .catch(console.error);
793
794
*/
794
- async fetchAuditLogs ( options = { } ) {
795
- if ( options . before && options . before instanceof GuildAuditLogs . Entry ) options . before = options . before . id ;
796
- if ( typeof options . type === 'string' ) options . type = GuildAuditLogs . Actions [ options . type ] ;
797
-
795
+ async fetchAuditLogs ( { before, after, limit, user, type } = { } ) {
798
796
const data = await this . client . api . guilds ( this . id ) [ 'audit-logs' ] . get ( {
799
797
query : {
800
- before : options . before ,
801
- limit : options . limit ,
802
- user_id : this . client . users . resolveId ( options . user ) ,
803
- action_type : options . type ,
798
+ before : before ?. id ?? before ,
799
+ after : after ?. id ?? after ,
800
+ limit,
801
+ user_id : this . client . users . resolveId ( user ) ,
802
+ action_type : typeof type === 'string' ? GuildAuditLogs . Actions [ type ] : type ,
804
803
} ,
805
804
} ) ;
805
+
806
806
return GuildAuditLogs . build ( this , data ) ;
807
807
}
808
808
0 commit comments