mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-02 08:50:07 +00:00
feat(client,rest,types): add GetAuditLog.after (#2898)
* feat(client,rest,types): add `GetAuditLog.after` closes: https://github.com/discordeno/discordeno/issues/2860 * Apply suggestions from code review --------- Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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<string, any>;
|
||||
const err = (await result.json().catch(() => {})) as Record<string, any>
|
||||
// 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) => {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user