mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 19:28:17 +00:00
14 lines
659 B
TypeScript
14 lines
659 B
TypeScript
import type { InviteMetadata } from "../../types/invites/invite_metadata.ts";
|
|
import { Collection } from "../../util/collection.ts";
|
|
import {SnakeCasedPropertiesDeep} from "../../types/util.ts";
|
|
import {Bot} from "../../bot.ts";
|
|
|
|
/** Get all the invites for this guild. Requires MANAGE_GUILD permission */
|
|
export async function getInvites(bot: Bot, guildId: bigint) {
|
|
await bot.utils.requireBotGuildPermissions(guildId, ["MANAGE_GUILD"]);
|
|
|
|
const result = await bot.rest.runMethod<SnakeCasedPropertiesDeep<InviteMetadata>[]>("get", bot.constants.endpoints.GUILD_INVITES(guildId));
|
|
|
|
return new Collection(result.map((invite) => [invite.code, invite]));
|
|
}
|