2023-07-03 21:13:08 +05:00
|
|
|
const { SlashCommandBuilder, PermissionsBitField, EmbedBuilder } = require("discord.js");
|
2022-07-31 18:52:16 +05:00
|
|
|
const BaseCommand = require("../../base/BaseCommand");
|
|
|
|
|
|
|
|
class Warns extends BaseCommand {
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
*/
|
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({
|
|
|
|
"uk": client.translate("moderation/warns:DESCRIPTION", null, "uk-UA"),
|
|
|
|
"ru": client.translate("moderation/warns:DESCRIPTION", null, "ru-RU"),
|
|
|
|
})
|
2022-10-13 00:05:36 +05:00
|
|
|
.setDMPermission(false)
|
2023-07-03 21:13:08 +05:00
|
|
|
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageMessages)
|
2022-08-03 21:13:22 +05:00
|
|
|
.addUserOption(option => option.setName("user")
|
|
|
|
.setDescription(client.translate("common:USER"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
|
|
|
"uk": client.translate("common:USER", null, "uk-UA"),
|
|
|
|
"ru": client.translate("common:USER", null, "ru-RU"),
|
|
|
|
})
|
2022-08-03 21:13:22 +05:00
|
|
|
.setRequired(true)),
|
2022-07-31 18:52:16 +05:00
|
|
|
aliases: [],
|
|
|
|
dirname: __dirname,
|
2022-12-15 21:02:38 +05:00
|
|
|
ownerOnly: false,
|
2022-07-31 18:52:16 +05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
*/
|
|
|
|
async onLoad() {
|
|
|
|
//...
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
2022-08-06 20:47:47 +05:00
|
|
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
2022-08-09 23:48:33 +05:00
|
|
|
* @param {Object} data
|
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
|
|
|
|
|
|
|
const memberData = await client.findOrCreateMember({
|
|
|
|
id: member.id,
|
2022-12-15 21:02:38 +05:00
|
|
|
guildId: interaction.guildId,
|
2022-07-31 18:52:16 +05:00
|
|
|
});
|
|
|
|
|
|
|
|
const embed = new EmbedBuilder()
|
|
|
|
.setAuthor({
|
|
|
|
name: interaction.translate("moderation/warns:SANCTIONS_OF", {
|
2022-12-15 21:02:38 +05:00
|
|
|
member: member.nickname || member.user.username,
|
2022-07-31 18:52:16 +05:00
|
|
|
}),
|
|
|
|
iconURL: member.displayAvatarURL({
|
2022-08-02 17:18:47 +05:00
|
|
|
extension: "png",
|
2022-12-15 21:02:38 +05:00
|
|
|
size: 512,
|
|
|
|
}),
|
2022-07-31 18:52:16 +05:00
|
|
|
})
|
|
|
|
.setColor(client.config.embed.color)
|
|
|
|
.setFooter({
|
2022-12-15 21:02:38 +05:00
|
|
|
text: client.config.embed.footer,
|
2022-07-31 18:52:16 +05:00
|
|
|
});
|
|
|
|
|
2022-08-03 21:13:22 +05:00
|
|
|
if (memberData.sanctions.length === 0) {
|
|
|
|
embed.setDescription(interaction.translate("moderation/warns:NO_SANCTIONS", {
|
2022-12-15 21:02:38 +05:00
|
|
|
member: member.nickname || member.user.username,
|
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 => {
|
2022-07-31 18:52:16 +05:00
|
|
|
embed.addFields([
|
|
|
|
{
|
2023-01-09 01:39:13 +05:00
|
|
|
name: sanction.type,
|
2022-08-03 21:13:22 +05:00
|
|
|
value: `${interaction.translate("common:MODERATOR")}: <@${sanction.moderator}>\n${interaction.translate("common:REASON")}: ${sanction.reason}`,
|
2022-12-15 21:02:38 +05:00
|
|
|
inline: true,
|
|
|
|
},
|
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
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Warns;
|