diff --git a/packages/client/src/typings.ts b/packages/client/src/typings.ts index 91197af3d..6e36184d7 100644 --- a/packages/client/src/typings.ts +++ b/packages/client/src/typings.ts @@ -18,7 +18,7 @@ import type { StickerTypes, VerificationLevels, VideoQualityModes, - WebhookTypes, + WebhookTypes } from '@discordeno/types' import type { IncomingHttpHeaders } from 'node:http' import type Collection from './Collection.js' @@ -438,6 +438,7 @@ export interface DiscoverySubcategoryResponse { export interface GetGuildAuditLogOptions { actionType?: number before?: string + after?: string limit?: number userID?: string } diff --git a/packages/rest/src/manager.ts b/packages/rest/src/manager.ts index bfd4998ca..1c3ddf0dd 100644 --- a/packages/rest/src/manager.ts +++ b/packages/rest/src/manager.ts @@ -321,6 +321,8 @@ export function createRestManager(options: CreateRestManagerOptions): RestManage // eslint-disable-next-line @typescript-eslint/restrict-template-expressions if (options.before) url += `&before=${options.before}` // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + if (options.after) url += `&after=${options.after}` + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions if (options.limit) url += `&limit=${options.limit}` // eslint-disable-next-line @typescript-eslint/restrict-template-expressions if (options.userId) url += `&user_id=${options.userId}` @@ -973,7 +975,7 @@ export function createRestManager(options: CreateRestManagerOptions): RestManage } const headers: HeadersInit = { - Authorization: rest.authorization ?? "", + Authorization: rest.authorization ?? '', } if (body) { headers['Content-Type'] = 'application/json' @@ -985,13 +987,13 @@ export function createRestManager(options: CreateRestManagerOptions): RestManage }) if (!result.ok) { - const err = await result.json().catch(() => {}) as Record; + const err = (await result.json().catch(() => {})) as Record // Legacy Handling to not break old code or when body is missing if (!err?.body) throw new Error(`Error: ${err.message ?? result.statusText}`) - throw new Error(JSON.stringify(err)); + throw new Error(JSON.stringify(err)) } - return result.status !== 204 ? await result.json() as any : undefined + return result.status !== 204 ? ((await result.json()) as any) : undefined } return await new Promise((resolve, reject) => { diff --git a/packages/types/src/discordeno.ts b/packages/types/src/discordeno.ts index 143b548a4..080e1640f 100644 --- a/packages/types/src/discordeno.ts +++ b/packages/types/src/discordeno.ts @@ -328,11 +328,13 @@ export interface ListArchivedThreads { /** https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log-query-string-parameters */ export interface GetGuildAuditLog { /** Entries from a specific user ID */ - userId?: BigString | string + userId?: BigString /** Entries for a specific audit log event */ actionType?: AuditLogEvents - /** Entries that preceded a specific audit log entry ID */ - before?: BigString | string + /** Entries with ID less than a specific audit log entry ID. */ + before?: BigString + /** Entries with ID greater than a specific audit log entry ID. */ + after?: BigString /** Maximum number of entries (between 1-100) to return, defaults to 50 */ limit?: number }