fix: remove get query loop loop de loop loop

This commit is contained in:
Skillz4Killz
2022-03-26 00:11:47 +00:00
committed by GitHub
parent 80d2e94840
commit b06f6d2512
15 changed files with 126 additions and 81 deletions
+10 -4
View File
@@ -4,15 +4,21 @@ import { AuditLogEvents } from "../../types/shared.ts";
/** Returns the audit logs for the guild. Requires VIEW AUDIT LOGS permission */
export async function getAuditLogs(bot: Bot, guildId: bigint, options?: GetGuildAuditLog) {
if (options?.userId) options.userId = options.userId.toString();
if (options?.before) options.before = options.before.toString();
if (options?.limit) options.limit = options.limit >= 1 && options.limit <= 100 ? options.limit : 50;
let url = bot.constants.endpoints.GUILD_AUDIT_LOGS(guildId);
if (options) {
url += "?";
if (options.actionType) url += `action_type=${options.actionType}`;
if (options.before) url += `&before=${options.before}`;
if (options.limit) url += `&limit=${options.limit}`;
if (options.userId) url += `&user_id=${options.userId}`;
}
const auditlog = await bot.rest.runMethod<DiscordAuditLog>(
bot.rest,
"get",
bot.constants.endpoints.GUILD_AUDIT_LOGS(guildId),
options,
url,
);
return {