import { MessageFlags, type ChatInputCommandInteraction, type PermissionResolvable, } from "discord.js"; import type { Middleware } from "../types/Middleware"; export function requirePermission( permission: PermissionResolvable, ): Middleware { return async (interaction, _client, next) => { if (!interaction.memberPermissions?.has(permission)) { await interaction.reply({ content: "You do not have permission to use this command.", flags: [MessageFlags.Ephemeral], }); return; } await next(); }; }