mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 03:18:17 +00:00
refactor(helpers): separate functions into files (#667)
* refactor(helpers): separate functions into files * idk * idk
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { RequestManager } from "../../rest/request_manager.ts";
|
||||
import { Errors, PruneOptions, PrunePayload } from "../../types/mod.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { requireBotGuildPermissions } from "../../util/permissions.ts";
|
||||
import { camelKeysToSnakeCase, urlToBase64 } from "../../util/utils.ts";
|
||||
|
||||
/** Check how many members would be removed from the server in a prune operation. Requires the KICK_MEMBERS permission */
|
||||
export async function getPruneCount(guildID: string, options?: PruneOptions) {
|
||||
if (options?.days && options.days < 1) throw new Error(Errors.PRUNE_MIN_DAYS);
|
||||
if (options?.days && options.days > 30) {
|
||||
throw new Error(Errors.PRUNE_MAX_DAYS);
|
||||
}
|
||||
|
||||
await requireBotGuildPermissions(guildID, ["KICK_MEMBERS"]);
|
||||
|
||||
const result = await RequestManager.get(
|
||||
endpoints.GUILD_PRUNE(guildID),
|
||||
camelKeysToSnakeCase(options ?? {}),
|
||||
) as PrunePayload;
|
||||
|
||||
return result.pruned;
|
||||
}
|
||||
Reference in New Issue
Block a user