2023-07-03 21:13:08 +05:00
|
|
|
const { SlashCommandBuilder, PermissionsBitField, ChannelType } = require("discord.js");
|
2022-08-08 18:19:56 +05:00
|
|
|
const BaseCommand = require("../../base/BaseCommand");
|
|
|
|
|
|
|
|
class Automod extends BaseCommand {
|
|
|
|
/**
|
|
|
|
*
|
2023-11-05 16:03:23 +05:00
|
|
|
* @param {import("../../base/Client")} client
|
2022-08-08 18:19:56 +05:00
|
|
|
*/
|
|
|
|
constructor(client) {
|
|
|
|
super({
|
|
|
|
command: new SlashCommandBuilder()
|
|
|
|
.setName("automod")
|
|
|
|
.setDescription(client.translate("administration/automod:DESCRIPTION"))
|
2023-03-26 18:31:19 +05:00
|
|
|
.setDescriptionLocalizations({
|
2023-07-05 00:58:06 +05:00
|
|
|
uk: client.translate("administration/automod:DESCRIPTION", null, "uk-UA"),
|
|
|
|
ru: client.translate("administration/automod:DESCRIPTION", null, "ru-RU"),
|
2023-03-26 18:31:19 +05:00
|
|
|
})
|
2022-10-13 00:05:36 +05:00
|
|
|
.setDMPermission(false)
|
2023-07-03 21:13:08 +05:00
|
|
|
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageGuild)
|
2023-10-30 21:13:12 +05:00
|
|
|
.addSubcommand(subcommand =>
|
|
|
|
subcommand
|
|
|
|
.setName("toggle")
|
|
|
|
.setDescription(client.translate("administration/automod:TOGGLE"))
|
2023-07-05 00:58:06 +05:00
|
|
|
.setDescriptionLocalizations({
|
2023-10-30 21:13:12 +05:00
|
|
|
uk: client.translate("administration/automod:TOGGLE", null, "uk-UA"),
|
|
|
|
ru: client.translate("administration/automod:TOGGLE", null, "ru-RU"),
|
2023-07-05 00:58:06 +05:00
|
|
|
})
|
2023-10-30 21:13:12 +05:00
|
|
|
.addBooleanOption(option =>
|
|
|
|
option
|
|
|
|
.setName("state")
|
|
|
|
.setDescription(client.translate("common:STATE"))
|
|
|
|
.setDescriptionLocalizations({
|
|
|
|
uk: client.translate("common:STATE", null, "uk-UA"),
|
|
|
|
ru: client.translate("common:STATE", null, "ru-RU"),
|
|
|
|
})
|
|
|
|
.setRequired(true),
|
|
|
|
),
|
2023-07-05 00:58:06 +05:00
|
|
|
)
|
2023-10-30 21:13:12 +05:00
|
|
|
.addSubcommand(subcommand =>
|
|
|
|
subcommand
|
|
|
|
.setName("ignore")
|
|
|
|
.setDescription(client.translate("administration/automod:IGNORE"))
|
2023-07-05 00:58:06 +05:00
|
|
|
.setDescriptionLocalizations({
|
2023-10-30 21:13:12 +05:00
|
|
|
uk: client.translate("administration/automod:IGNORE", null, "uk-UA"),
|
|
|
|
ru: client.translate("administration/automod:IGNORE", null, "ru-RU"),
|
2023-07-05 00:58:06 +05:00
|
|
|
})
|
2023-10-30 21:13:12 +05:00
|
|
|
.addChannelOption(option =>
|
|
|
|
option
|
|
|
|
.setName("channel")
|
|
|
|
.setDescription(client.translate("common:CHANNEL"))
|
|
|
|
.setDescriptionLocalizations({
|
|
|
|
uk: client.translate("common:CHANNEL", null, "uk-UA"),
|
|
|
|
ru: client.translate("common:CHANNEL", null, "ru-RU"),
|
|
|
|
})
|
|
|
|
.addChannelTypes(ChannelType.GuildText)
|
|
|
|
.setRequired(true),
|
|
|
|
),
|
2023-07-05 00:58:06 +05:00
|
|
|
),
|
2022-08-08 18:19:56 +05:00
|
|
|
dirname: __dirname,
|
2022-12-15 21:02:38 +05:00
|
|
|
ownerOnly: false,
|
2022-08-08 18:19:56 +05:00
|
|
|
});
|
|
|
|
}
|
2024-02-06 21:45:53 +05:00
|
|
|
|
2022-08-08 18:19:56 +05:00
|
|
|
/**
|
|
|
|
*
|
2023-11-05 16:03:23 +05:00
|
|
|
* @param {import("../../base/Client")} client
|
2022-08-08 18:19:56 +05:00
|
|
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
|
|
|
*/
|
2024-02-09 23:26:57 +05:00
|
|
|
async execute(client, interaction) {
|
|
|
|
const { data } = interaction,
|
|
|
|
state = interaction.options.getBoolean("state"),
|
2023-10-30 21:13:12 +05:00
|
|
|
channel = interaction.options.getChannel("channel"),
|
|
|
|
command = interaction.options.getSubcommand();
|
2022-08-08 18:19:56 +05:00
|
|
|
|
2023-10-30 21:13:12 +05:00
|
|
|
if (command === "toggle") {
|
2024-02-09 23:26:57 +05:00
|
|
|
data.guild.plugins.automod = {
|
2023-10-30 21:13:12 +05:00
|
|
|
enabled: state,
|
2022-12-15 21:02:38 +05:00
|
|
|
ignored: [],
|
2022-08-08 18:19:56 +05:00
|
|
|
};
|
2023-09-25 21:42:43 +05:00
|
|
|
|
2024-02-09 23:26:57 +05:00
|
|
|
await data.guild.save();
|
2023-01-09 01:39:13 +05:00
|
|
|
|
2023-10-30 21:13:12 +05:00
|
|
|
interaction.success(`administration/automod:${state ? "ENABLED" : "DISABLED"}`);
|
|
|
|
} else if (command === "ignore") {
|
2024-02-09 23:26:57 +05:00
|
|
|
data.guild.plugins.automod.ignored.push(channel.id);
|
2023-09-25 21:42:43 +05:00
|
|
|
|
2024-02-09 23:26:57 +05:00
|
|
|
await data.guild.save();
|
2023-01-09 01:39:13 +05:00
|
|
|
|
2023-10-30 21:13:12 +05:00
|
|
|
interaction.success("administration/automod:DISABLED_CHANNEL", {
|
|
|
|
channel: channel.toString(),
|
|
|
|
});
|
2022-08-08 18:19:56 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-05 00:58:06 +05:00
|
|
|
module.exports = Automod;
|