3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-07-12 05:27:19 +00:00
zeppelin/backend/src/plugins/SelfGrantableRoles/util/getApplyingEntries.ts

15 lines
556 B
TypeScript

import { GuildPluginData } from "knub";
import { SelfGrantableRolesPluginType, TSelfGrantableRoleEntry } from "../types";
export async function getApplyingEntries(
pluginData: GuildPluginData<SelfGrantableRolesPluginType>,
msg,
): Promise<TSelfGrantableRoleEntry[]> {
const config = await pluginData.config.getForMessage(msg);
return Object.entries(config.entries)
.filter(
([k, e]) =>
e.can_use && !(!e.can_ignore_cooldown && pluginData.state.cooldowns.isOnCooldown(`${k}:${msg.author.id}`)),
)
.map(pair => pair[1]);
}