mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 11:28:15 +00:00
guilds
This commit is contained in:
@@ -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]),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user