parent
27dca8890a
commit
aa04fd7311
@ -782,7 +782,8 @@ class Guild extends AnonymousGuild {
|
|||||||
/**
|
/**
|
||||||
* Options used to fetch audit logs.
|
* Options used to fetch audit logs.
|
||||||
* @typedef {Object} GuildAuditLogsFetchOptions
|
* @typedef {Object} GuildAuditLogsFetchOptions
|
||||||
* @property {Snowflake|GuildAuditLogsEntry} [before] Only return entries before this entry
|
* @property {Snowflake|GuildAuditLogsEntry} [before] Consider only entries before this entry
|
||||||
|
* @property {Snowflake|GuildAuditLogsEntry} [after] Consider only entries after this entry
|
||||||
* @property {number} [limit] The number of entries to return
|
* @property {number} [limit] The number of entries to return
|
||||||
* @property {UserResolvable} [user] Only return entries for actions made by this user
|
* @property {UserResolvable} [user] Only return entries for actions made by this user
|
||||||
* @property {AuditLogAction|number} [type] Only return entries for this action type
|
* @property {AuditLogAction|number} [type] Only return entries for this action type
|
||||||
@ -798,20 +799,14 @@ class Guild extends AnonymousGuild {
|
|||||||
* .then(audit => console.log(audit.entries.first()))
|
* .then(audit => console.log(audit.entries.first()))
|
||||||
* .catch(console.error);
|
* .catch(console.error);
|
||||||
*/
|
*/
|
||||||
async fetchAuditLogs(options = {}) {
|
async fetchAuditLogs({ before, after, limit, user, type } = {}) {
|
||||||
if (options.before && options.before instanceof GuildAuditLogs.Entry) {
|
|
||||||
options.before = options.before.id;
|
|
||||||
}
|
|
||||||
if (typeof options.type === 'string') {
|
|
||||||
options.type = GuildAuditLogs.Actions[options.type];
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = await this.client.api.guilds(this.id)['audit-logs'].get({
|
const data = await this.client.api.guilds(this.id)['audit-logs'].get({
|
||||||
query: {
|
query: {
|
||||||
before: options.before,
|
before: before?.id ?? before,
|
||||||
limit: options.limit,
|
after: after?.id ?? after,
|
||||||
user_id: this.client.users.resolveId(options.user),
|
limit,
|
||||||
action_type: options.type,
|
user_id: this.client.users.resolveId(user),
|
||||||
|
action_type: typeof type === 'string' ? GuildAuditLogs.Actions[type] : type,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return GuildAuditLogs.build(this, data);
|
return GuildAuditLogs.build(this, data);
|
||||||
|
1
typings/index.d.ts
vendored
1
typings/index.d.ts
vendored
@ -5907,6 +5907,7 @@ export interface GuildAuditLogsEntryTargetField<TActionType extends GuildAuditLo
|
|||||||
|
|
||||||
export interface GuildAuditLogsFetchOptions<T extends GuildAuditLogsResolvable> {
|
export interface GuildAuditLogsFetchOptions<T extends GuildAuditLogsResolvable> {
|
||||||
before?: Snowflake | GuildAuditLogsEntry;
|
before?: Snowflake | GuildAuditLogsEntry;
|
||||||
|
after?: Snowflake | GuildAuditLogsEntry;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
user?: UserResolvable;
|
user?: UserResolvable;
|
||||||
type?: T;
|
type?: T;
|
||||||
|
Loading…
Reference in New Issue
Block a user