Skip to content

Commit f0d4264

Browse files
authoredJan 10, 2023
feat(GuildAuditLogs): Support after (#9012)
1 parent 6457519 commit f0d4264

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed
 

‎src/structures/Guild.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,8 @@ class Guild extends AnonymousGuild {
775775
/**
776776
* Options used to fetch audit logs.
777777
* @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
779780
* @property {number} [limit] The number of entries to return
780781
* @property {UserResolvable} [user] Only return entries for actions made by this user
781782
* @property {AuditLogAction|number} [type] Only return entries for this action type
@@ -791,18 +792,17 @@ class Guild extends AnonymousGuild {
791792
* .then(audit => console.log(audit.entries.first()))
792793
* .catch(console.error);
793794
*/
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 } = {}) {
798796
const data = await this.client.api.guilds(this.id)['audit-logs'].get({
799797
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,
804803
},
805804
});
805+
806806
return GuildAuditLogs.build(this, data);
807807
}
808808

‎typings/index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5024,6 +5024,7 @@ export interface GuildAuditLogsEntryTargetField<TActionType extends GuildAuditLo
50245024

50255025
export interface GuildAuditLogsFetchOptions<T extends GuildAuditLogsResolvable> {
50265026
before?: Snowflake | GuildAuditLogsEntry;
5027+
after?: Snowflake | GuildAuditLogsEntry;
50275028
limit?: number;
50285029
user?: UserResolvable;
50295030
type?: T;

0 commit comments

Comments
 (0)
Please sign in to comment.