This commit is contained in:
ITOH
2021-04-24 19:38:06 +02:00
parent a1d0986edf
commit 933a5c70eb
12 changed files with 57 additions and 53 deletions
+4 -5
View File
@@ -1,20 +1,19 @@
import { rest } from "../../rest/rest.ts";
import { Ban, DiscordBan } from "../../types/guilds/ban.ts";
import { Ban } from "../../types/guilds/ban.ts";
import { Collection } from "../../util/collection.ts";
import { endpoints } from "../../util/constants.ts";
import { requireBotGuildPermissions } from "../../util/permissions.ts";
import { snakeKeysToCamelCase } from "../../util/utils.ts";
/** Returns a list of ban objects for the users banned from this guild. Requires the BAN_MEMBERS permission. */
export async function getBans(guildId: string) {
await requireBotGuildPermissions(guildId, ["BAN_MEMBERS"]);
const results = (await rest.runMethod(
const results = await rest.runMethod<Ban[]>(
"get",
endpoints.GUILD_BANS(guildId),
)) as DiscordBan[];
);
return new Collection<string, Ban>(
results.map((res) => [res.user.id, snakeKeysToCamelCase<Ban>(res)]),
results.map((res) => [res.user.id, res]),
);
}