/** * @copyright nhcarrigan * @license Naomi's Public License * @author Naomi Carrigan */ import { entitledGuilds, entitledUsers } from "../config/entitlements.js"; /** * Checks if a user has subscribed. * @param hikari - Hikari's Discord instance. * @param user - The user to check. * @returns A boolean indicating whether the user has an active subscription. */ const checkUserEntitlement = async (hikari, user) => { if (entitledUsers.includes(user.id)) { return true; } const entitlements = await hikari.application?.entitlements.fetch({ excludeDeleted: true, excludeEnded: true, user: user, }); return Boolean(entitlements && entitlements.size > 0); }; /** * Checks if a guild has subscribed. * @param hikari - Hikari's Discord instance. * @param guild - The guild to check. * @returns A boolean indicating whether the guild has an active subscription. */ const checkGuildEntitlement = async (hikari, guild) => { if (entitledGuilds.includes(guild.id)) { return true; } const entitlements = await hikari.application?.entitlements.fetch({ excludeDeleted: true, excludeEnded: true, guild: guild, }); return Boolean(entitlements && entitlements.size > 0); }; export { checkUserEntitlement, checkGuildEntitlement };