Локализация permissions

This commit is contained in:
JonnyBro 2022-02-06 16:10:34 +05:00
parent e79d799b7a
commit 2b0b96729d
2 changed files with 9 additions and 5 deletions

View file

@ -21,22 +21,26 @@ class Permissions extends Command {
async run(message) { async run(message) {
const member = message.mentions.members.first() || message.member; const member = message.mentions.members.first() || message.member;
let text = "```\n" + `${message.translate("general/permissions:TITLE", { user: member.user.username, channel: message.channel.name })}\n\n`;
const mPermissions = message.channel.permissionsFor(member); const mPermissions = message.channel.permissionsFor(member);
const total = { const total = {
denied: 0, denied: 0,
allowed: 0 allowed: 0
}; };
let text = `${message.translate("general/permissions:TITLE", { user: member.user.username, channel: message.channel.name })}\n\n`;
permissions.forEach((perm) => { permissions.forEach((perm) => {
if (perm === "REQUEST_TO_SPEAK") return;
if (!mPermissions.has(perm)) { if (!mPermissions.has(perm)) {
text += `${perm}\n`; text += `${message.translate(`misc:PERMISSIONS:${perm}`)}\n`;
total.denied++; total.denied++;
} else { } else {
text += `${perm}\n`; text += `${message.translate(`misc:PERMISSIONS:${perm}`)}\n`;
total.allowed++; total.allowed++;
} }
}); });
text += `\n${total.allowed} ✅ | ${total.denied}` + "\n```"; text += `\n${total.allowed} ✅ | ${total.denied}`;
message.channel.send({ message.channel.send({
content: text content: text
}); });

View file

@ -145,7 +145,7 @@ module.exports = class {
if (!message.channel.permissionsFor(message.member).has(perm)) neededPermissions.push(perm); if (!message.channel.permissionsFor(message.member).has(perm)) neededPermissions.push(perm);
}); });
if (neededPermissions.length > 0) return message.error("misc:MISSING_MEMBER_PERMS", { list: neededPermissions.map((p) => `\`${message.translate(`misc:PERMISSIONS:${p.toUpperCase()}`)}\``).join(", ") }); if (neededPermissions.length > 0) return message.error("misc:MISSING_MEMBER_PERMS", { list: neededPermissions.map((p) => `\`${message.translate(`misc:PERMISSIONS:${p}`)}\``).join(", ") });
if (!message.channel.permissionsFor(message.member).has(Permissions.FLAGS.MENTION_EVERYONE) && (message.content.includes("@everyone") || message.content.includes("@here"))) return message.error("misc:EVERYONE_MENTION"); if (!message.channel.permissionsFor(message.member).has(Permissions.FLAGS.MENTION_EVERYONE) && (message.content.includes("@everyone") || message.content.includes("@here"))) return message.error("misc:EVERYONE_MENTION");
if (!message.channel.nsfw && cmd.conf.nsfw) return message.error("misc:NSFW_COMMAND"); if (!message.channel.nsfw && cmd.conf.nsfw) return message.error("misc:NSFW_COMMAND");
} }