import { MessageFlags, type ChatInputCommandInteraction } from "discord.js"; import type { Middleware } from "@voidy/framework"; import { UserConsent } from "../schemas/UserConsent"; export function requireConsent( ...types: ("storage" | "statistics")[] ): Middleware { return async (interaction, _client, next) => { const doc = await UserConsent.findOne({ userId: interaction.user.id }); for (const type of types) { if (!doc?.consent[type]) { await interaction.reply({ content: `This command requires your **${type}** consent. Use \`/user consent update\` to enable it.`, flags: [MessageFlags.Ephemeral], }); return; } } await next(); }; }