2024-02-06 21:45:53 +05:00
|
|
|
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js");
|
2022-07-31 18:52:16 +05:00
|
|
|
const BaseCommand = require("../../base/BaseCommand");
|
|
|
|
|
|
|
|
class Warns extends BaseCommand {
|
|
|
|
/**
|
|
|
|
*
|
2023-11-05 16:03:23 +05:00
|
|
|
* @param {import("../../base/Client")} client
|
2022-07-31 18:52:16 +05:00
|
|
|
*/
|
2022-08-03 21:13:22 +05:00
|
|
|
constructor(client) {
|
2022-07-31 18:52:16 +05:00
|
|
|
super({
|
2022-08-03 21:13:22 +05:00
|
|
|
command: new SlashCommandBuilder()
|
2022-07-31 18:52:16 +05:00
|
|
|
.setName("warns")
|
2022-08-03 21:13:22 +05:00
|
|
|
.setDescription(client.translate("moderation/warns:DESCRIPTION"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
2023-07-05 00:58:06 +05:00
|
|
|
uk: client.translate("moderation/warns:DESCRIPTION", null, "uk-UA"),
|
|
|
|
ru: client.translate("moderation/warns:DESCRIPTION", null, "ru-RU"),
|
2023-06-15 19:46:27 +05:00
|
|
|
})
|
2022-10-13 00:05:36 +05:00
|
|
|
.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),
|
|
|
|
),
|
2022-07-31 18:52:16 +05:00
|
|
|
dirname: __dirname,
|
2022-12-15 21:02:38 +05:00
|
|
|
ownerOnly: false,
|
2022-07-31 18:52:16 +05:00
|
|
|
});
|
|
|
|
}
|
2024-02-06 21:45:53 +05:00
|
|
|
|
2022-07-31 18:52:16 +05:00
|
|
|
/**
|
|
|
|
*
|
2023-11-05 16:03:23 +05:00
|
|
|
* @param {import("../../base/Client")} client
|
2022-08-06 20:47:47 +05:00
|
|
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
2022-07-31 18:52:16 +05:00
|
|
|
*/
|
|
|
|
async execute(client, interaction) {
|
2022-08-03 21:13:22 +05:00
|
|
|
const member = interaction.options.getMember("user");
|
|
|
|
if (member.user.bot) return interaction.error("misc:BOT_USER");
|
2022-07-31 18:52:16 +05:00
|
|
|
|
2024-05-24 23:02:12 +05:00
|
|
|
const memberData = await client.findOrCreateMember(member.id, interaction.guildId);
|
2022-07-31 18:52:16 +05:00
|
|
|
|
2024-02-06 21:45:53 +05:00
|
|
|
const embed = client.embed({
|
|
|
|
author: {
|
2022-07-31 18:52:16 +05:00
|
|
|
name: interaction.translate("moderation/warns:SANCTIONS_OF", {
|
2023-07-03 21:14:53 +05:00
|
|
|
member: member.user.getUsername(),
|
2022-07-31 18:52:16 +05:00
|
|
|
}),
|
2023-07-05 00:58:06 +05:00
|
|
|
iconURL: member.displayAvatarURL(),
|
2024-02-06 21:45:53 +05:00
|
|
|
},
|
|
|
|
});
|
2022-07-31 18:52:16 +05:00
|
|
|
|
2022-08-03 21:13:22 +05:00
|
|
|
if (memberData.sanctions.length === 0) {
|
2024-02-06 21:45:53 +05:00
|
|
|
embed.data.description = interaction.translate("moderation/warns:NO_SANCTIONS", {
|
|
|
|
member: member.user.getUsername(),
|
|
|
|
});
|
|
|
|
|
2022-07-31 18:52:16 +05:00
|
|
|
return interaction.reply({
|
2022-12-15 21:02:38 +05:00
|
|
|
embeds: [embed],
|
2022-07-31 18:52:16 +05:00
|
|
|
});
|
|
|
|
} else {
|
2022-08-03 21:13:22 +05:00
|
|
|
memberData.sanctions.forEach(sanction => {
|
2024-02-06 21:45:53 +05:00
|
|
|
embed.data.fields.push({
|
|
|
|
name: sanction.type,
|
|
|
|
value: `${interaction.translate("common:MODERATOR")}: <@${sanction.moderator}>\n${interaction.translate("common:REASON")}: ${sanction.reason}`,
|
|
|
|
inline: true,
|
|
|
|
});
|
2022-07-31 18:52:16 +05:00
|
|
|
});
|
|
|
|
}
|
2023-07-05 00:58:06 +05:00
|
|
|
|
2022-07-31 18:52:16 +05:00
|
|
|
interaction.reply({
|
2022-12-15 21:02:38 +05:00
|
|
|
embeds: [embed],
|
2022-07-31 18:52:16 +05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-05 00:58:06 +05:00
|
|
|
module.exports = Warns;
|