mirror of
https://github.com/sern-handler/awesome-plugins
synced 2026-06-15 04:12:30 +00:00
chore: Update JavaScript plugins (#69)
chore: update JavaScript plugins Co-authored-by: EvolutionX-10 <EvolutionX-10@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
98ab449203
commit
b2ee0996f1
@@ -1,3 +1,5 @@
|
||||
// @ts-nocheck
|
||||
|
||||
/**
|
||||
* This is perm check, it allows users to parse the permission you want and let the plugin do the rest. (check bot or user for that perm).
|
||||
*
|
||||
@@ -16,7 +18,7 @@
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
import { PluginType } from "@sern/handler";
|
||||
import { CommandControlPlugin, controller } from "@sern/handler";
|
||||
|
||||
function payload(resp) {
|
||||
return {
|
||||
@@ -29,78 +31,66 @@ function payload(resp) {
|
||||
}
|
||||
|
||||
export function requirePermission(target, perm, response) {
|
||||
return {
|
||||
type: PluginType.Event,
|
||||
description: "Checks bot/user perms",
|
||||
return CommandControlPlugin(async (ctx, args) => {
|
||||
if (ctx.guild === null) {
|
||||
ctx.reply(payload("This command cannot be used here"));
|
||||
console.warn(
|
||||
"PermCheck > A command stopped because we couldn't check a users permissions (was used in dms)"
|
||||
); //delete this line if you dont want to be notified when a command is used outside of a guild/server
|
||||
|
||||
async execute(event, controller) {
|
||||
const [ctx] = event;
|
||||
return controller.stop();
|
||||
}
|
||||
|
||||
if (ctx.guild === null) {
|
||||
ctx.reply(payload("This command cannot be used here"));
|
||||
console.warn(
|
||||
"PermCheck > A command stopped because we couldn't check a users permissions (was used in dms)"
|
||||
); //delete this line if you dont want to be notified when a command is used outside of a guild/server
|
||||
const bot = await ctx.guild.members.fetchMe({
|
||||
cache: false,
|
||||
});
|
||||
const memm = ctx.member;
|
||||
|
||||
return controller.stop();
|
||||
}
|
||||
|
||||
const bot = await ctx.guild.members.fetchMe({
|
||||
cache: false,
|
||||
});
|
||||
const memm = ctx.member;
|
||||
|
||||
switch (target) {
|
||||
//*********************************************************************************************************************//
|
||||
case "bot":
|
||||
if (!bot.permissions.has(perm)) {
|
||||
if (!response)
|
||||
response = `I cannot use this command, please give me \`${perm.join(
|
||||
", "
|
||||
)}\` permission(s).`;
|
||||
await ctx.reply(payload(response));
|
||||
return controller.stop();
|
||||
}
|
||||
|
||||
return controller.next();
|
||||
//*********************************************************************************************************************//
|
||||
|
||||
case "user":
|
||||
if (!memm.permissions.has(perm)) {
|
||||
if (!response)
|
||||
response = `You cannot use this command because you are missing \`${perm.join(
|
||||
", "
|
||||
)}\` permission(s).`;
|
||||
await ctx.reply(payload(response));
|
||||
return controller.stop();
|
||||
}
|
||||
|
||||
return controller.next();
|
||||
//*********************************************************************************************************************//
|
||||
|
||||
case "both":
|
||||
if (
|
||||
!bot.permissions.has(perm) ||
|
||||
!memm.permissions.has(perm)
|
||||
) {
|
||||
if (!response)
|
||||
response = `Please ensure <@${bot.user.id}> and <@${
|
||||
memm.user.id
|
||||
}> both have \`${perm.join(", ")}\` permission(s).`;
|
||||
await ctx.reply(payload(response));
|
||||
return controller.stop();
|
||||
}
|
||||
|
||||
return controller.next();
|
||||
//*********************************************************************************************************************//
|
||||
|
||||
default:
|
||||
console.warn(
|
||||
"Perm Check >>> You didn't specify user or bot."
|
||||
);
|
||||
ctx.reply(payload("User or Bot was not specified."));
|
||||
switch (target) {
|
||||
//*********************************************************************************************************************//
|
||||
case "bot":
|
||||
if (!bot.permissions.has(perm)) {
|
||||
if (!response)
|
||||
response = `I cannot use this command, please give me \`${perm.join(
|
||||
", "
|
||||
)}\` permission(s).`;
|
||||
await ctx.reply(payload(response));
|
||||
return controller.stop();
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return controller.next();
|
||||
//*********************************************************************************************************************//
|
||||
|
||||
case "user":
|
||||
if (!memm.permissions.has(perm)) {
|
||||
if (!response)
|
||||
response = `You cannot use this command because you are missing \`${perm.join(
|
||||
", "
|
||||
)}\` permission(s).`;
|
||||
await ctx.reply(payload(response));
|
||||
return controller.stop();
|
||||
}
|
||||
|
||||
return controller.next();
|
||||
//*********************************************************************************************************************//
|
||||
|
||||
case "both":
|
||||
if (!bot.permissions.has(perm) || !memm.permissions.has(perm)) {
|
||||
if (!response)
|
||||
response = `Please ensure <@${bot.user.id}> and <@${
|
||||
memm.user.id
|
||||
}> both have \`${perm.join(", ")}\` permission(s).`;
|
||||
await ctx.reply(payload(response));
|
||||
return controller.stop();
|
||||
}
|
||||
|
||||
return controller.next();
|
||||
//*********************************************************************************************************************//
|
||||
|
||||
default:
|
||||
console.warn("Perm Check >>> You didn't specify user or bot.");
|
||||
ctx.reply(payload("User or Bot was not specified."));
|
||||
return controller.stop();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user