mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
20 lines
774 B
TypeScript
20 lines
774 B
TypeScript
import type { Ban } from "../../types/guilds/ban.ts";
|
|
import type { Bot } from "../../bot.ts";
|
|
import { Collection } from "../../util/collection.ts";
|
|
import { DiscordenoUser } from "../../transformers/member.ts";
|
|
|
|
/** Returns a list of ban objects for the users banned from this guild. Requires the BAN_MEMBERS permission. */
|
|
export async function getBans(bot: Bot, guildId: bigint) {
|
|
const results = await bot.rest.runMethod<Ban[]>(bot.rest, "get", bot.constants.endpoints.GUILD_BANS(guildId));
|
|
|
|
return new Collection<bigint, { reason?: string; user: DiscordenoUser }>(
|
|
results.map((res) => [
|
|
bot.transformers.snowflake(res.user.id),
|
|
{
|
|
reason: res.reason ?? undefined,
|
|
user: bot.transformers.user(bot, res.user),
|
|
},
|
|
]),
|
|
);
|
|
}
|