mirror of
https://github.com/SrIzan10/awesome-plugins.git
synced 2026-05-01 10:35:27 +00:00
chore: Update JavaScript plugins (#66)
chore: update JavaScript plugins Co-authored-by: jacoobes <jacoobes@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
6d0e581512
commit
50017c37cd
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* @author @Benzo-Fury [<@762918086349029386>]
|
||||
* @author @needhamgary [<@342314924804014081>]
|
||||
* @version 1.1.0
|
||||
* @version 1.2.0
|
||||
* @example
|
||||
* ```ts
|
||||
* import { requirePermission } from "../plugins/myPermCheck";
|
||||
@@ -22,6 +22,9 @@ function payload(resp) {
|
||||
return {
|
||||
fetchReply: true,
|
||||
content: resp,
|
||||
allowedMentions: {
|
||||
repliedUser: false,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -42,32 +45,54 @@ export function requirePermission(target, perm, response) {
|
||||
return controller.stop();
|
||||
}
|
||||
|
||||
const bot = await ctx.guild.members.fetchMe({
|
||||
cache: false,
|
||||
});
|
||||
const memm = ctx.member;
|
||||
|
||||
switch (target) {
|
||||
//*********************************************************************************************************************//
|
||||
case "bot":
|
||||
if (
|
||||
!(
|
||||
await ctx.guild.members.fetchMe({
|
||||
cache: false,
|
||||
})
|
||||
).permissions.has(perm)
|
||||
) {
|
||||
if (!bot.permissions.has(perm)) {
|
||||
if (!response)
|
||||
response = `I cannot use this command, please give me \`${perm}\` permission.`;
|
||||
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 (!ctx.member.permissions.has(perm)) {
|
||||
if (!memm.permissions.has(perm)) {
|
||||
if (!response)
|
||||
response = `You cannot use this command because you are missing \`${perm}\` permission.`;
|
||||
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(
|
||||
|
||||
Reference in New Issue
Block a user