2022-08-03 21:13:22 +05:00
|
|
|
const { SlashCommandBuilder, PermissionFlagsBits, 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"))
|
|
|
|
.setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers && PermissionFlagsBits.ManageMessages)
|
|
|
|
.addUserOption(option => option.setName("user")
|
|
|
|
.setDescription(client.translate("common:USER"))
|
|
|
|
.setRequired(true)),
|
2022-07-31 18:52:16 +05:00
|
|
|
aliases: [],
|
|
|
|
dirname: __dirname,
|
|
|
|
guildOnly: true
|
|
|
|
});
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
*/
|
|
|
|
async onLoad() {
|
|
|
|
//...
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
* @param {import("discord.js").UserContextMenuCommandInteraction} interaction
|
|
|
|
* @param {Array} data
|
|
|
|
*/
|
|
|
|
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,
|
|
|
|
guildID: interaction.guildId
|
|
|
|
});
|
|
|
|
|
|
|
|
const embed = new EmbedBuilder()
|
|
|
|
.setAuthor({
|
|
|
|
name: interaction.translate("moderation/warns:SANCTIONS_OF", {
|
|
|
|
member: member.nickname || member.user.username
|
|
|
|
}),
|
|
|
|
iconURL: member.displayAvatarURL({
|
2022-08-02 17:18:47 +05:00
|
|
|
extension: "png",
|
|
|
|
size: 512
|
2022-07-31 18:52:16 +05:00
|
|
|
})
|
|
|
|
})
|
|
|
|
.setColor(client.config.embed.color)
|
|
|
|
.setFooter({
|
|
|
|
text: client.config.embed.footer
|
|
|
|
});
|
|
|
|
|
2022-08-03 21:13:22 +05:00
|
|
|
if (memberData.sanctions.length === 0) {
|
|
|
|
embed.setDescription(interaction.translate("moderation/warns:NO_SANCTIONS", {
|
2022-07-31 18:52:16 +05:00
|
|
|
member: member.nickname || member.user.username
|
|
|
|
}));
|
|
|
|
return interaction.reply({
|
|
|
|
embeds: [embed]
|
|
|
|
});
|
|
|
|
} else {
|
2022-08-03 21:13:22 +05:00
|
|
|
memberData.sanctions.forEach(sanction => {
|
2022-07-31 18:52:16 +05:00
|
|
|
embed.addFields([
|
|
|
|
{
|
2022-08-03 21:13:22 +05:00
|
|
|
name: sanction.type + " | #" + sanction.case,
|
|
|
|
value: `${interaction.translate("common:MODERATOR")}: <@${sanction.moderator}>\n${interaction.translate("common:REASON")}: ${sanction.reason}`,
|
2022-07-31 18:52:16 +05:00
|
|
|
inline: true
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
interaction.reply({
|
|
|
|
embeds: [embed]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Warns;
|