JaBa/commands/General/report.js

107 lines
3 KiB
JavaScript
Raw Permalink Normal View History

2024-09-19 23:58:06 +05:00
const { SlashCommandBuilder, parseEmoji, InteractionContextType, ApplicationIntegrationType } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand");
class Report extends BaseCommand {
/**
*
2023-11-05 16:03:23 +05:00
* @param {import("../base/Client")} client
*/
constructor(client) {
super({
command: new SlashCommandBuilder()
.setName("report")
.setDescription(client.translate("general/report:DESCRIPTION"))
.setDescriptionLocalizations({
2023-07-05 00:58:06 +05:00
uk: client.translate("general/report:DESCRIPTION", null, "uk-UA"),
ru: client.translate("general/report:DESCRIPTION", null, "ru-RU"),
})
2024-09-19 23:58:06 +05:00
.setIntegrationTypes([ApplicationIntegrationType.GuildInstall])
2024-09-14 19:52:56 +05:00
.setContexts([InteractionContextType.Guild])
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),
)
.addStringOption(option =>
option
.setName("message")
.setDescription(client.translate("common:MESSAGE"))
.setDescriptionLocalizations({
uk: client.translate("common:MESSAGE", null, "uk-UA"),
ru: client.translate("common:MESSAGE", 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
*/
2024-02-09 23:26:57 +05:00
async execute(client, interaction) {
const guildData = interaction.data.guild,
repChannel = interaction.guild.channels.cache.get(guildData.plugins.reports);
if (!repChannel) return interaction.error("general/report:MISSING_CHANNEL");
2023-06-27 21:19:55 +05:00
const member = interaction.options.getMember("user");
if (member.id === interaction.user.id) return interaction.error("general/report:INVALID_USER");
2023-06-27 21:19:55 +05:00
const rep = interaction.options.getString("message");
const embed = client.embed({
author: {
name: interaction.translate("general/report:TITLE", {
user: member.user.getUsername(),
}),
iconURL: interaction.user.displayAvatarURL(),
},
fields: [
{
name: interaction.translate("common:DATE"),
value: `<t:${Math.floor(Date.now() / 1000)}:D>`,
},
{
name: interaction.translate("common:AUTHOR"),
value: interaction.user.toString(),
inline: true,
},
{
name: interaction.translate("common:USER"),
value: member.user.toString(),
inline: true,
},
{
name: interaction.translate("common:REASON"),
value: rep,
inline: true,
},
],
});
2024-07-31 21:06:43 +05:00
const cool = parseEmoji(client.customEmojis.cool).id;
const notcool = parseEmoji(client.customEmojis.notcool).id;
repChannel.send({
embeds: [embed],
}).then(async m => {
2024-07-31 21:06:43 +05:00
await m.react(cool);
await m.react(notcool);
});
interaction.success("general/report:SUCCESS", {
channel: repChannel.toString(),
}, { ephemeral: true });
}
}
2023-07-05 00:58:06 +05:00
module.exports = Report;