JaBa/commands/Administration/automod.js

55 lines
1.5 KiB
JavaScript
Raw Normal View History

2022-01-04 02:18:28 +05:00
const Command = require("../../base/Command.js");
class Automod extends Command {
constructor(client) {
super(client, {
name: "automod",
dirname: __dirname,
enabled: true,
guildOnly: true,
aliases: ["autom"],
memberPermissions: ["MANAGE_GUILD"],
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
nsfw: false,
ownerOnly: false,
cooldown: 1000
});
}
async run(message, args, data) {
const status = args[0];
if (!status || (status !== "on" && status !== "off")) return message.error("administration/automod:MISSING_STATUS");
if (status === "on") {
data.guild.plugins.automod = {
enabled: true,
ignored: []
};
data.guild.markModified("plugins.automod");
data.guild.save();
message.success("administration/automod:ENABLED", {
prefix: data.guild.prefix
});
} else if (status === "off") {
if (message.mentions.channels.filter((ch) => ch.type === "GUILD_TEXT" && ch.guild.id === message.guild.id).first()) {
2022-01-04 02:18:28 +05:00
const channel = message.mentions.channels.first();
data.guild.plugins.automod.ignored.push(channel);
data.guild.markModified("plugins.automod");
data.guild.save();
message.success("administration/automod:DISABLED_CHANNEL", {
channel: channel.toString()
});
} else {
data.guild.plugins.automod = {
enabled: false,
ignored: []
};
data.guild.markModified("plugins.automod");
data.guild.save();
message.success("administration/automod:DISABLED");
};
};
}
};
module.exports = Automod;