2022-08-08 18:19:56 +05:00
|
|
|
const { SlashCommandBuilder, PermissionFlagsBits, ChannelType } = require("discord.js");
|
|
|
|
const BaseCommand = require("../../base/BaseCommand");
|
|
|
|
|
|
|
|
class Automod extends BaseCommand {
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
*/
|
|
|
|
constructor(client) {
|
|
|
|
super({
|
|
|
|
command: new SlashCommandBuilder()
|
|
|
|
.setName("automod")
|
|
|
|
.setDescription(client.translate("administration/automod:DESCRIPTION"))
|
2022-10-13 00:05:36 +05:00
|
|
|
.setDMPermission(false)
|
2022-11-09 21:33:45 +05:00
|
|
|
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
2022-08-08 18:19:56 +05:00
|
|
|
.addBooleanOption(option => option.setName("state")
|
|
|
|
.setDescription(client.translate("common:STATE"))
|
|
|
|
.setRequired(true))
|
|
|
|
.addChannelOption(option => option.setName("channel")
|
|
|
|
.setDescription(client.translate("common:CHANNEL"))
|
|
|
|
.addChannelTypes(ChannelType.GuildText)),
|
|
|
|
aliases: [],
|
|
|
|
dirname: __dirname,
|
2022-12-15 21:02:38 +05:00
|
|
|
ownerOnly: false,
|
2022-08-08 18:19:56 +05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
*/
|
|
|
|
async onLoad() {
|
|
|
|
//...
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
2022-08-09 23:48:33 +05:00
|
|
|
* @param {Object} data
|
2022-08-08 18:19:56 +05:00
|
|
|
*/
|
|
|
|
async execute(client, interaction, data) {
|
2023-01-09 01:39:13 +05:00
|
|
|
const state = interaction.options.getBoolean("state"),
|
|
|
|
channel = interaction.options.getChannel("channel");
|
2022-08-08 18:19:56 +05:00
|
|
|
|
|
|
|
if (state) {
|
|
|
|
data.guildData.plugins.automod = {
|
|
|
|
enabled: true,
|
2022-12-15 21:02:38 +05:00
|
|
|
ignored: [],
|
2022-08-08 18:19:56 +05:00
|
|
|
};
|
|
|
|
data.guildData.markModified("plugins.automod");
|
|
|
|
await data.guildData.save();
|
2023-01-09 01:39:13 +05:00
|
|
|
|
2022-08-08 18:19:56 +05:00
|
|
|
return interaction.success("administration/automod:ENABLED");
|
|
|
|
} else {
|
|
|
|
if (channel) {
|
|
|
|
data.guildData.plugins.automod.ignored.push(channel);
|
|
|
|
data.guildData.markModified("plugins.automod");
|
|
|
|
await data.guildData.save();
|
2023-01-09 01:39:13 +05:00
|
|
|
|
2022-08-08 18:19:56 +05:00
|
|
|
interaction.success("administration/automod:DISABLED_CHANNEL", {
|
2022-12-15 21:02:38 +05:00
|
|
|
channel: channel.toString(),
|
2022-08-08 18:19:56 +05:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
data.guildData.plugins.automod = {
|
|
|
|
enabled: false,
|
2022-12-15 21:02:38 +05:00
|
|
|
ignored: [],
|
2022-08-08 18:19:56 +05:00
|
|
|
};
|
|
|
|
data.guildData.markModified("plugins.automod");
|
|
|
|
await data.guildData.save();
|
2023-01-09 01:39:13 +05:00
|
|
|
|
2022-08-08 18:19:56 +05:00
|
|
|
interaction.success("administration/automod:DISABLED");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Automod;
|