JaBa/commands/General/report.js

60 lines
1.9 KiB
JavaScript
Raw Normal View History

2021-12-10 21:39:54 +05:00
const Command = require("../../base/Command.js"),
Discord = require("discord.js");
class Report extends Command {
2021-12-26 19:29:37 +05:00
constructor(client) {
2021-12-10 21:39:54 +05:00
super(client, {
name: "report",
dirname: __dirname,
enabled: true,
guildOnly: true,
aliases: [],
memberPermissions: [],
2021-12-26 19:29:37 +05:00
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
2021-12-10 21:39:54 +05:00
nsfw: false,
ownerOnly: false,
cooldown: 2000
2021-12-10 21:39:54 +05:00
});
}
2021-12-26 19:29:37 +05:00
async run(message, args, data) {
2021-12-10 21:39:54 +05:00
const repChannel = message.guild.channels.cache.get(data.guild.plugins.reports);
if (!repChannel) return message.error("general/report:MISSING_CHANNEL");
const member = await this.client.resolveMember(args[0], message.guild);
if (!member) return message.error("general/report:MISSING_USER");
if (member.id === message.author.id) return message.error("general/report:INVALID_USER");
const rep = args.slice(1).join(" ");
if (!rep) return message.error("general/report:MISSING_REASON");
const embed = new Discord.MessageEmbed()
2022-01-03 23:20:33 +05:00
.setAuthor({ name: message.translate("general/report:TITLE", {
2021-12-26 19:29:37 +05:00
user: member.user.tag
2022-01-03 23:20:33 +05:00
}), iconURL: message.author.displayAvatarURL({
2021-12-26 19:29:37 +05:00
size: 512,
dynamic: true,
format: "png"
2022-01-03 23:20:33 +05:00
})})
2021-12-10 21:39:54 +05:00
.addField(message.translate("common:AUTHOR"), message.author.tag, true)
.addField(message.translate("common:DATE"), message.printDate(new Date(Date.now())), true)
2021-12-29 01:47:01 +05:00
.addField(message.translate("common:REASON"), rep, true)
2021-12-10 21:39:54 +05:00
.addField(message.translate("common:USER"), `\`${member.user.tag}\` (${member.user.toString()})`, true)
.setColor(data.config.embed.color)
2022-01-03 23:20:33 +05:00
.setFooter({ text: data.config.embed.footer });
2021-12-10 21:39:54 +05:00
const success = Discord.Util.parseEmoji(this.client.customEmojis.success).id;
const error = Discord.Util.parseEmoji(this.client.customEmojis.error).id;
2022-01-03 23:20:33 +05:00
repChannel.send({ embeds: [embed] }).then(async (m) => {
2021-12-10 21:39:54 +05:00
await m.react(success);
await m.react(error);
});
2021-12-26 19:29:37 +05:00
message.success("general/report:SUCCESS", {
channel: repChannel.toString()
});
2021-12-10 21:39:54 +05:00
}
};
module.exports = Report;