3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-25 02:25:01 +00:00
zeppelin/backend/src/plugins/SelfGrantableRoles/util/getApplyingEntries.ts
2021-09-11 19:06:51 +03:00

15 lines
558 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]);
}