A powerful and extendable Discord bot, with it's own module system :3
thevoid.cafe/projects/voidy
1import { MessageFlags, type ChatInputCommandInteraction } from "discord.js";
2import type { Middleware } from "@voidy/framework";
3import { UserConsent } from "../schemas/UserConsent";
4
5export function requireConsent(
6 ...types: ("storage" | "statistics")[]
7): Middleware<ChatInputCommandInteraction> {
8 return async (interaction, _client, next) => {
9 const doc = await UserConsent.findOne({ userId: interaction.user.id });
10
11 for (const type of types) {
12 if (!doc?.consent[type]) {
13 await interaction.reply({
14 content: `This command requires your **${type}** consent. Use \`/user consent update\` to enable it.`,
15 flags: [MessageFlags.Ephemeral],
16 });
17 return;
18 }
19 }
20
21 await next();
22 };
23}