mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-25 02:25:01 +00:00
15 lines
558 B
TypeScript
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]);
|
|
}
|