mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-03 09:20:08 +00:00
25 lines
830 B
TypeScript
25 lines
830 B
TypeScript
import type { GetGuildPruneCountQuery } from "../../types/guilds/getGuildPruneCount.ts";
|
|
import type { Bot } from "../../bot.ts";
|
|
|
|
/** Check how many members would be removed from the server in a prune operation. Requires the KICK_MEMBERS permission */
|
|
export async function getPruneCount(bot: Bot, guildId: bigint, options?: GetGuildPruneCountQuery) {
|
|
if (options?.days && options.days < 1) throw new Error(bot.constants.Errors.PRUNE_MIN_DAYS);
|
|
if (options?.days && options.days > 30) {
|
|
throw new Error(bot.constants.Errors.PRUNE_MAX_DAYS);
|
|
}
|
|
|
|
const result = await bot.rest.runMethod(
|
|
bot.rest,
|
|
"get",
|
|
bot.constants.endpoints.GUILD_PRUNE(guildId),
|
|
options
|
|
? {
|
|
days: options.days,
|
|
include_roles: options.includeRoles,
|
|
}
|
|
: {},
|
|
);
|
|
|
|
return result.pruned as number;
|
|
}
|