mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 03:18:17 +00:00
fir more things
This commit is contained in:
@@ -1,27 +1,30 @@
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { AuditLog } from "../../types/audit_log/audit_log.ts";
|
||||
import { GetGuildAuditLog } from "../../types/audit_log/get_guild_audit_log.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { requireBotGuildPermissions } from "../../util/permissions.ts";
|
||||
import {
|
||||
camelKeysToSnakeCase,
|
||||
snakeKeysToCamelCase,
|
||||
} from "../../util/utils.ts";
|
||||
|
||||
/** Returns the audit logs for the guild. Requires VIEW AUDIT LOGS permission */
|
||||
export async function getAuditLogs(
|
||||
guildId: string,
|
||||
options: GetAuditLogsOptions,
|
||||
options: GetGuildAuditLog,
|
||||
) {
|
||||
await requireBotGuildPermissions(guildId, ["VIEW_AUDIT_LOG"]);
|
||||
|
||||
const result = await rest.runMethod(
|
||||
"get",
|
||||
endpoints.GUILD_AUDIT_LOGS(guildId),
|
||||
{
|
||||
camelKeysToSnakeCase({
|
||||
...options,
|
||||
action_type: options.action_type
|
||||
? AuditLogs[options.action_type]
|
||||
: undefined,
|
||||
limit: options.limit && options.limit >= 1 && options.limit <= 100
|
||||
? options.limit
|
||||
: 50,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
return result;
|
||||
return snakeKeysToCamelCase(result) as AuditLog;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user