JaBa/commands/Moderation/clearwarns.js

61 lines
1.6 KiB
JavaScript
Raw Normal View History

2023-07-03 21:13:08 +05:00
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand");
class Clearwarns extends BaseCommand {
/**
*
2023-11-05 16:03:23 +05:00
* @param {import("../../base/Client")} client
*/
constructor(client) {
super({
command: new SlashCommandBuilder()
.setName("clearwarns")
.setDescription(client.translate("moderation/clearwarns:DESCRIPTION"))
.setDescriptionLocalizations({
2023-07-05 00:58:06 +05:00
uk: client.translate("moderation/clearwarns:DESCRIPTION", null, "uk-UA"),
ru: client.translate("moderation/clearwarns:DESCRIPTION", null, "ru-RU"),
})
.setDMPermission(false)
2023-07-03 21:13:08 +05:00
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageMessages)
2023-07-05 00:58:06 +05:00
.addUserOption(option =>
option
.setName("user")
.setDescription(client.translate("common:USER"))
.setDescriptionLocalizations({
uk: client.translate("common:USER", null, "uk-UA"),
ru: client.translate("common:USER", null, "ru-RU"),
})
.setRequired(true),
),
dirname: __dirname,
ownerOnly: false,
});
}
/**
*
2023-11-05 16:03:23 +05:00
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
2022-08-09 23:48:33 +05:00
* @param {Object} data
*/
async execute(client, interaction) {
const member = interaction.options.getMember("user");
const memberData = await client.findOrCreateMember({
id: member.id,
guildId: interaction.guildId,
});
memberData.sanctions = [];
2023-10-30 21:45:10 +05:00
memberData.markModified("sanctions");
2023-10-17 08:33:41 +05:00
await memberData.save();
interaction.success("moderation/clearwarns:SUCCESS", {
2023-03-19 22:15:16 +05:00
user: member.toString(),
});
}
}
2023-07-05 00:58:06 +05:00
module.exports = Clearwarns;