JaBa/commands/Moderation/setwarns.js

68 lines
2.6 KiB
JavaScript
Raw Normal View History

2021-12-10 21:39:54 +05:00
const Command = require("../../base/Command.js");
class Setwarns extends Command {
2021-12-26 19:29:37 +05:00
constructor(client) {
2021-12-10 21:39:54 +05:00
super(client, {
name: "setwarns",
dirname: __dirname,
enabled: true,
guildOnly: true,
aliases: [],
2021-12-26 19:29:37 +05:00
memberPermissions: ["MANAGE_GUILD"],
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS", "BAN_MEMBERS", "KICK_MEMBERS"],
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, args, data) {
2021-12-10 21:39:54 +05:00
const sanction = args[0];
2021-12-11 01:11:50 +05:00
if (!sanction || (sanction !== "kick" && sanction !== "ban")) return message.error("moderation/setwarns:MISSING_TYPE");
2021-12-10 21:39:54 +05:00
const number = args[1];
2021-12-11 01:11:50 +05:00
if (number === "reset") {
if (sanction === "kick") {
2021-12-10 21:39:54 +05:00
data.guild.plugins.warnsSanctions.kick = false;
data.guild.markModified("plugins.warnsSanctions");
data.guild.save();
2021-12-26 19:29:37 +05:00
return message.success("moderation/setwarns:SUCCESS_KICK_RESET", {
prefix: data.guild.prefix,
2021-12-30 20:03:36 +05:00
count: `${number} ${this.client.getNoun(number, message.translate("misc:NOUNS:WARNS:1"), message.translate("misc:NOUNS:WARNS:2"), message.translate("misc:NOUNS:WARNS:5"))}`
2021-12-26 19:29:37 +05:00
});
2021-12-11 21:08:37 +05:00
} else if (sanction === "ban") {
2021-12-10 21:39:54 +05:00
data.guild.plugins.warnsSanctions.ban = false;
data.guild.markModified("plugins.warnsSanctions");
data.guild.save();
2021-12-26 19:29:37 +05:00
return message.success("moderation/setwarns:SUCCESS_BAN_RESET", {
prefix: data.guild.prefix,
2021-12-30 20:03:36 +05:00
count: `${number} ${this.client.getNoun(number, message.translate("misc:NOUNS:WARNS:1"), message.translate("misc:NOUNS:WARNS:2"), message.translate("misc:NOUNS:WARNS:5"))}`
2021-12-26 19:29:37 +05:00
});
2021-12-11 01:11:50 +05:00
};
};
2021-12-10 21:39:54 +05:00
2021-12-11 01:11:50 +05:00
if (!number || isNaN(number)) return message.error("misc:INVALID_NUMBER");
if (number < 1 || number > 10) return message.error("misc:INVALID_NUMBER_RANGE", 1, 10);
2021-12-10 21:39:54 +05:00
2021-12-11 01:11:50 +05:00
if (sanction === "kick") {
2021-12-10 21:39:54 +05:00
data.guild.plugins.warnsSanctions.kick = number;
data.guild.markModified("plugins.warnsSanctions");
data.guild.save();
2021-12-26 19:29:37 +05:00
return message.success("moderation/setwarns:SUCCESS_KICK", {
prefix: data.guild.prefix,
2021-12-30 20:03:36 +05:00
count: `${number} ${this.client.getNoun(number, message.translate("misc:NOUNS:WARNS:1"), message.translate("misc:NOUNS:WARNS:2"), message.translate("misc:NOUNS:WARNS:5"))}`
2021-12-26 19:29:37 +05:00
});
2021-12-11 01:11:50 +05:00
} else if (sanction === "ban") {
2021-12-10 21:39:54 +05:00
data.guild.plugins.warnsSanctions.ban = number;
data.guild.markModified("plugins.warnsSanctions");
data.guild.save();
2021-12-26 19:29:37 +05:00
return message.success("moderation/setwarns:SUCCESS_BAN", {
prefix: data.guild.prefix,
2021-12-30 20:03:36 +05:00
count: `${number} ${this.client.getNoun(number, message.translate("misc:NOUNS:WARNS:1"), message.translate("misc:NOUNS:WARNS:2"), message.translate("misc:NOUNS:WARNS:5"))}`
2021-12-26 19:29:37 +05:00
});
2021-12-11 01:11:50 +05:00
};
2021-12-10 21:39:54 +05:00
}
2021-12-11 01:11:50 +05:00
};
2021-12-10 21:39:54 +05:00
module.exports = Setwarns;