JaBa/commands/Moderation/warns.js

83 lines
2.2 KiB
JavaScript
Raw Permalink Normal View History

const { SlashCommandBuilder, PermissionsBitField } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand");
class Warns extends BaseCommand {
/**
*
2023-11-05 16:03:23 +05:00
* @param {import("../../base/Client")} client
*/
2022-08-03 21:13:22 +05:00
constructor(client) {
super({
2022-08-03 21:13:22 +05:00
command: new SlashCommandBuilder()
.setName("warns")
2022-08-03 21:13:22 +05:00
.setDescription(client.translate("moderation/warns:DESCRIPTION"))
.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"),
})
.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
*/
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");
const memberData = await client.findOrCreateMember({
id: member.id,
guildId: interaction.guildId,
});
const embed = client.embed({
author: {
name: interaction.translate("moderation/warns:SANCTIONS_OF", {
2023-07-03 21:14:53 +05:00
member: member.user.getUsername(),
}),
2023-07-05 00:58:06 +05:00
iconURL: member.displayAvatarURL(),
},
});
2022-08-03 21:13:22 +05:00
if (memberData.sanctions.length === 0) {
embed.data.description = interaction.translate("moderation/warns:NO_SANCTIONS", {
member: member.user.getUsername(),
});
return interaction.reply({
embeds: [embed],
});
} else {
2022-08-03 21:13:22 +05:00
memberData.sanctions.forEach(sanction => {
embed.data.fields.push({
name: sanction.type,
value: `${interaction.translate("common:MODERATOR")}: <@${sanction.moderator}>\n${interaction.translate("common:REASON")}: ${sanction.reason}`,
inline: true,
});
});
}
2023-07-05 00:58:06 +05:00
interaction.reply({
embeds: [embed],
});
}
}
2023-07-05 00:58:06 +05:00
module.exports = Warns;