JaBa/commands/Administration/automod.js

55 lines
1.5 KiB
JavaScript
Raw Normal View History

2021-12-10 21:39:54 +05:00
const Command = require("../../base/Command.js");
class Automod extends Command {
2021-12-26 19:29:37 +05:00
constructor(client) {
2021-12-10 21:39:54 +05:00
super(client, {
name: "automod",
dirname: __dirname,
enabled: true,
guildOnly: true,
aliases: ["autom"],
2021-12-26 19:29:37 +05:00
memberPermissions: ["MANAGE_GUILD"],
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, args, data) {
2021-12-10 21:39:54 +05:00
const status = args[0];
if (!status || (status !== "on" && status !== "off")) return message.error("administration/automod:MISSING_STATUS");
if (status === "on") {
2021-12-26 19:29:37 +05:00
data.guild.plugins.automod = {
enabled: true,
ignored: []
};
2021-12-10 21:39:54 +05:00
data.guild.markModified("plugins.automod");
data.guild.save();
2021-12-26 19:29:37 +05:00
message.success("administration/automod:ENABLED", {
prefix: data.guild.prefix
});
2021-12-10 21:39:54 +05:00
} else if (status === "off") {
if (message.mentions.channels.filter((ch) => ch.type === "text" && ch.guild.id === message.guild.id).first()) {
const channel = message.mentions.channels.first();
data.guild.plugins.automod.ignored.push(channel);
data.guild.markModified("plugins.automod");
data.guild.save();
2021-12-26 19:29:37 +05:00
message.success("administration/automod:DISABLED_CHANNEL", {
channel: channel.toString()
});
2021-12-10 21:39:54 +05:00
} else {
2021-12-26 19:29:37 +05:00
data.guild.plugins.automod = {
enabled: false,
ignored: []
};
2021-12-10 21:39:54 +05:00
data.guild.markModified("plugins.automod");
data.guild.save();
message.success("administration/automod:DISABLED");
};
};
}
};
module.exports = Automod;