mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-04 18:00:08 +00:00
18 lines
585 B
TypeScript
18 lines
585 B
TypeScript
import { Bot } from "../../../bot.ts";
|
|
import { DiscordAutoModerationRule } from "../../../types/discord.ts";
|
|
import { Collection } from "../../../util/collection.ts";
|
|
|
|
/** Get a list of all rules currently configured for guild. */
|
|
export async function getAutomodRules(bot: Bot, guildId: bigint) {
|
|
const rules = await bot.rest.runMethod<DiscordAutoModerationRule[]>(
|
|
bot.rest,
|
|
"GET",
|
|
bot.constants.routes.AUTOMOD_RULES(guildId),
|
|
);
|
|
|
|
return new Collection(rules.map((r) => {
|
|
const rule = bot.transformers.automodRule(bot, r);
|
|
return [rule.id, rule];
|
|
}));
|
|
}
|