2022-08-04 19:26:17 +05:00
|
|
|
const { SlashCommandBuilder, EmbedBuilder, parseEmoji } = require("discord.js");
|
|
|
|
const BaseCommand = require("../../base/BaseCommand");
|
|
|
|
|
|
|
|
class Report extends BaseCommand {
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../base/JaBa")} client
|
|
|
|
*/
|
|
|
|
constructor(client) {
|
|
|
|
super({
|
|
|
|
command: new SlashCommandBuilder()
|
|
|
|
.setName("report")
|
|
|
|
.setDescription(client.translate("general/report:DESCRIPTION"))
|
2023-03-26 18:31:19 +05:00
|
|
|
.setDescriptionLocalizations({ "uk": client.translate("general/report:DESCRIPTION", null, "uk-UA") })
|
2022-10-13 00:05:36 +05:00
|
|
|
.setDMPermission(false)
|
2022-08-04 19:26:17 +05:00
|
|
|
.addUserOption(option => option.setName("user")
|
|
|
|
.setDescription(client.translate("common:USER"))
|
2023-03-26 18:31:19 +05:00
|
|
|
.setDescriptionLocalizations({ "uk": client.translate("common:USER", null, "uk-UA") })
|
2022-08-04 19:26:17 +05:00
|
|
|
.setRequired(true))
|
|
|
|
.addStringOption(option => option.setName("message")
|
|
|
|
.setDescription(client.translate("common:MESSAGE"))
|
2023-03-26 18:31:19 +05:00
|
|
|
.setDescriptionLocalizations({ "uk": client.translate("common:MESSAGE", null, "uk-UA") })
|
2022-08-04 19:26:17 +05:00
|
|
|
.setRequired(true)),
|
|
|
|
aliases: [],
|
|
|
|
dirname: __dirname,
|
2022-12-15 21:02:38 +05:00
|
|
|
ownerOnly: false,
|
2022-08-04 19:26:17 +05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
*/
|
|
|
|
async onLoad() {
|
|
|
|
//...
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
2022-08-09 23:48:33 +05:00
|
|
|
* @param {Object} data
|
2022-08-04 19:26:17 +05:00
|
|
|
*/
|
|
|
|
async execute(client, interaction) {
|
|
|
|
const repChannel = interaction.guild.channels.cache.get(interaction.guild.data.plugins.reports);
|
|
|
|
if (!repChannel) return interaction.error("general/report:MISSING_CHANNEL");
|
|
|
|
const member = interaction.options.getMember("user");
|
|
|
|
if (member.id === interaction.user.id) return interaction.error("general/report:INVALID_USER");
|
|
|
|
const rep = interaction.options.getString("message");
|
|
|
|
|
|
|
|
const embed = new EmbedBuilder()
|
|
|
|
.setAuthor({
|
|
|
|
name: interaction.translate("general/report:TITLE", {
|
2022-12-15 21:02:38 +05:00
|
|
|
user: member.user.tag,
|
2022-08-04 19:26:17 +05:00
|
|
|
}),
|
|
|
|
iconURL: interaction.user.displayAvatarURL({
|
|
|
|
extension: "png",
|
2022-12-15 21:02:38 +05:00
|
|
|
size: 512,
|
|
|
|
}),
|
2022-08-04 19:26:17 +05:00
|
|
|
})
|
|
|
|
.addFields([
|
|
|
|
{
|
|
|
|
name: interaction.translate("common:DATE"),
|
2022-12-15 21:02:38 +05:00
|
|
|
value: client.printDate(new Date(Date.now())),
|
2022-08-04 19:26:17 +05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: interaction.translate("common:AUTHOR"),
|
|
|
|
value: interaction.user.toString(),
|
2022-12-15 21:02:38 +05:00
|
|
|
inline: true,
|
2022-08-04 19:26:17 +05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: interaction.translate("common:USER"),
|
|
|
|
value: member.user.toString(),
|
2022-12-15 21:02:38 +05:00
|
|
|
inline: true,
|
2022-08-04 19:26:17 +05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: interaction.translate("common:REASON"),
|
|
|
|
value: rep,
|
2022-12-15 21:02:38 +05:00
|
|
|
inline: true,
|
|
|
|
},
|
2022-08-04 19:26:17 +05:00
|
|
|
])
|
|
|
|
.setColor(client.config.embed.color)
|
|
|
|
.setFooter({
|
2022-12-15 21:02:38 +05:00
|
|
|
text: client.config.embed.footer,
|
2022-08-04 19:26:17 +05:00
|
|
|
});
|
|
|
|
|
|
|
|
const success = parseEmoji(client.customEmojis.cool).id;
|
|
|
|
const error = parseEmoji(client.customEmojis.notcool).id;
|
|
|
|
|
|
|
|
repChannel.send({
|
2022-12-15 21:02:38 +05:00
|
|
|
embeds: [embed],
|
2022-08-06 20:47:47 +05:00
|
|
|
}).then(async m => {
|
2022-08-04 19:26:17 +05:00
|
|
|
await m.react(success);
|
|
|
|
await m.react(error);
|
|
|
|
});
|
|
|
|
|
|
|
|
interaction.success("general/report:SUCCESS", {
|
2022-12-15 21:02:38 +05:00
|
|
|
channel: repChannel.toString(),
|
2023-01-09 01:39:13 +05:00
|
|
|
}, { ephemeral: true });
|
2022-08-04 19:26:17 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Report;
|