style: pretty

This commit is contained in:
EvolutionX
2022-07-29 09:09:19 +05:30
parent e2ea80a4b6
commit 9284587487

View File

@@ -19,27 +19,32 @@
import { PermissionResolvable, type GuildMember } from "discord.js";
import { CommandType, EventPlugin, PluginType } from "@sern/handler";
export function permCheck(perm: PermissionResolvable, response: string): EventPlugin<CommandType.Both> {
return {
type: PluginType.Event,
description: "Checks for specified perm",
async execute(event, controller) {
const [ctx] = event;
if(ctx.guild == null) {
ctx.reply('This command cannot be used here')
console.warn('A command stopped because we couldn\'t check there permissions (was used in dms)') //delete this line if you dont was to be notified when a command is used outside of a guild/server
return controller.stop()
}
if(!(ctx.member! as GuildMember).permissions.has(perm)) {
try {
await ctx.reply(response)
return controller.stop()
} catch {
ctx.reply("You do not have the required permissions")
return controller.stop()
}
}
return controller.next()
},
};
export function permCheck(
perm: PermissionResolvable,
response: string
): EventPlugin<CommandType.Both> {
return {
type: PluginType.Event,
description: "Checks for specified perm",
async execute(event, controller) {
const [ctx] = event;
if (ctx.guild == null) {
ctx.reply("This command cannot be used here");
console.warn(
"A command stopped because we couldn't check there permissions (was used in dms)"
); //delete this line if you dont was to be notified when a command is used outside of a guild/server
return controller.stop();
}
if (!(ctx.member! as GuildMember).permissions.has(perm)) {
try {
await ctx.reply(response);
return controller.stop();
} catch {
ctx.reply("You do not have the required permissions");
return controller.stop();
}
}
return controller.next();
},
};
}