JaBa/commands/General/permissions.js

44 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-12-10 21:39:54 +05:00
const Command = require("../../base/Command.js"),
Discord = require("discord.js");
2021-12-26 19:29:37 +05:00
2021-12-10 21:39:54 +05:00
const permissions = Object.keys(Discord.Permissions.FLAGS);
class Permissions extends Command {
2021-12-26 19:29:37 +05:00
constructor(client) {
2021-12-10 21:39:54 +05:00
super(client, {
name: "permissions",
dirname: __dirname,
enabled: true,
guildOnly: true,
2021-12-26 19:29:37 +05:00
aliases: ["perms"],
2021-12-10 21:39:54 +05:00
memberPermissions: [],
2021-12-26 19:29:37 +05:00
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
2021-12-10 21:39:54 +05:00
nsfw: false,
ownerOnly: false,
cooldown: 1000
2021-12-10 21:39:54 +05:00
});
}
2021-12-26 19:29:37 +05:00
async run(message) {
2021-12-10 21:39:54 +05:00
const member = message.mentions.members.first() || message.member;
2021-12-24 20:52:27 +05:00
let text = "```\n" + `${message.translate("general/permissions:TITLE", { user: member.user.username, channel: message.channel.name })}\n\n`;
2021-12-10 21:39:54 +05:00
const mPermissions = message.channel.permissionsFor(member);
const total = {
denied: 0,
allowed: 0
};
permissions.forEach((perm) => {
if (!mPermissions.has(perm)) {
text += `${perm}\n`;
total.denied++;
} else {
text += `${perm}\n`;
total.allowed++;
};
});
2021-12-24 20:52:27 +05:00
text += `\n${total.allowed} ✅ | ${total.denied}` + "\n```";
2021-12-10 21:39:54 +05:00
message.channel.send(text);
}
};
module.exports = Permissions;