fir more things

This commit is contained in:
ITOH
2021-04-07 10:27:44 +02:00
parent 941ebd3beb
commit 313e7d2d35
16 changed files with 74 additions and 38 deletions
+7 -3
View File
@@ -1,11 +1,15 @@
import { rest } from "../../rest/rest.ts";
import { GetGuildPruneCountQuery } from "../../types/guilds/get_guild_prune_count.ts";
import { Errors } from "../../types/misc/errors.ts";
import { endpoints } from "../../util/constants.ts";
import { requireBotGuildPermissions } from "../../util/permissions.ts";
import { camelKeysToSnakeCase } 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) {
export async function getPruneCount(
guildId: string,
options?: GetGuildPruneCountQuery,
) {
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);
@@ -17,7 +21,7 @@ export async function getPruneCount(guildId: string, options?: PruneOptions) {
"get",
endpoints.GUILD_PRUNE(guildId),
camelKeysToSnakeCase(options ?? {}),
) as PrunePayload;
);
return result.pruned;
return result.pruned as number;
}