A powerful and extendable Discord bot, with it's own module system :3
thevoid.cafe/projects/voidy
1import {
2 MessageFlags,
3 type ChatInputCommandInteraction,
4 type PermissionResolvable,
5} from "discord.js";
6import type { Middleware } from "../types/Middleware";
7
8export function requirePermission(
9 permission: PermissionResolvable,
10): Middleware<ChatInputCommandInteraction> {
11 return async (interaction, _client, next) => {
12 if (!interaction.memberPermissions?.has(permission)) {
13 await interaction.reply({
14 content: "You do not have permission to use this command.",
15 flags: [MessageFlags.Ephemeral],
16 });
17 return;
18 }
19
20 await next();
21 };
22}