2022-01-13 00:56:24 +05:00
|
|
|
const Command = require("../../base/Command"),
|
2022-01-04 02:18:28 +05:00
|
|
|
Discord = require("discord.js");
|
|
|
|
|
|
|
|
class Invitations extends Command {
|
|
|
|
constructor(client) {
|
|
|
|
super(client, {
|
|
|
|
name: "invitations",
|
|
|
|
dirname: __dirname,
|
|
|
|
enabled: true,
|
|
|
|
guildOnly: true,
|
|
|
|
aliases: ["invs"],
|
|
|
|
memberPermissions: [],
|
|
|
|
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS", "MANAGE_GUILD"],
|
|
|
|
nsfw: false,
|
|
|
|
ownerOnly: false,
|
|
|
|
cooldown: 1000
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async run(message, args, data) {
|
|
|
|
let member = await this.client.resolveMember(args[0], message.guild);
|
|
|
|
if (!member) member = message.member;
|
|
|
|
|
2022-01-05 00:24:57 +05:00
|
|
|
const invites = await message.guild.invites.fetch().catch(() => {});
|
2022-01-04 02:18:28 +05:00
|
|
|
if (!invites) return message.error("misc:ERR_OCCURRED");
|
|
|
|
|
|
|
|
const memberInvites = invites.filter((i) => i.inviter && i.inviter.id === member.user.id);
|
|
|
|
|
|
|
|
if (memberInvites.size <= 0) {
|
|
|
|
if (member === message.member) {
|
|
|
|
return message.error("general/invitations:NOBODY_AUTHOR");
|
|
|
|
} else {
|
|
|
|
return message.error("general/invitations:NOBODY_MEMBER", {
|
|
|
|
member: member.user.tag
|
|
|
|
});
|
2022-01-13 00:26:23 +05:00
|
|
|
}
|
|
|
|
}
|
2022-01-04 02:18:28 +05:00
|
|
|
|
|
|
|
const content = memberInvites.map((i) => {
|
|
|
|
return message.translate("general/invitations:CODE", {
|
|
|
|
uses: i.uses,
|
|
|
|
code: i.code,
|
|
|
|
channel: i.channel.toString()
|
|
|
|
});
|
|
|
|
}).join("\n");
|
|
|
|
let index = 0;
|
|
|
|
memberInvites.forEach((invite) => index += invite.uses);
|
|
|
|
|
|
|
|
const embed = new Discord.MessageEmbed()
|
|
|
|
.setColor(data.config.embed.color)
|
2022-01-05 00:24:57 +05:00
|
|
|
.setFooter({
|
|
|
|
text: data.config.embed.footer
|
|
|
|
})
|
|
|
|
.setAuthor({
|
|
|
|
name: message.translate("general/invitations:TRACKER")
|
|
|
|
})
|
2022-01-04 02:18:28 +05:00
|
|
|
.setDescription(message.translate("general/invitations:TITLE", {
|
|
|
|
member: member.user.tag,
|
|
|
|
guild: message.guild.name
|
|
|
|
}))
|
|
|
|
.addField(message.translate("general/invitations:FIELD_INVITED"), message.translate("general/invitations:FIELD_MEMBERS", {
|
|
|
|
total: index
|
|
|
|
}))
|
|
|
|
.addField(message.translate("general/invitations:FIELD_CODES"), content);
|
|
|
|
|
2022-01-05 00:24:57 +05:00
|
|
|
message.channel.send({
|
|
|
|
embeds: [embed]
|
|
|
|
});
|
2022-01-04 02:18:28 +05:00
|
|
|
}
|
2022-01-13 00:26:23 +05:00
|
|
|
}
|
2022-01-04 02:18:28 +05:00
|
|
|
|
|
|
|
module.exports = Invitations;
|