JaBa/commands/Moderation/checkinvites.js

47 lines
1.4 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 Checkinvites extends Command {
constructor (client) {
super(client, {
name: "checkinvites",
dirname: __dirname,
enabled: true,
guildOnly: true,
aliases: [ "checkinvite", "checki" ],
memberPermissions: [],
botPermissions: [ "SEND_MESSAGES", "EMBED_LINKS" ],
nsfw: false,
ownerOnly: false,
cooldown: 3000
});
}
async run (message, args, data) {
const members = message.guild.members;
const withInvite = [];
members.cache.forEach((m) => {
const possibleLinks = m.user.presence.activities.map((a) => [ a.state, a.details, a.name ]).flat();
const inviteLinks = possibleLinks.filter((l) => /(discord\.(gg|io|me|li)\/.+|discordapp\.com\/invite\/.+)/i.test(l));
2021-12-11 01:11:50 +05:00
if (inviteLinks.length > 0) {
2021-12-10 21:39:54 +05:00
withInvite.push({
id: m.user.id,
tag: Discord.Util.escapeMarkdown(m.user.tag),
links: "**"+Discord.Util.escapeMarkdown(inviteLinks.join(", "))+"**"
});
2021-12-11 01:11:50 +05:00
};
2021-12-10 21:39:54 +05:00
});
2021-12-11 01:11:50 +05:00
const text = (withInvite.length > 0 ? withInvite.map((m) => "`"+m.id+"` ("+m.tag+") : "+m.links).join("\n") : message.translate("moderation/checkinvites:NOBODY"));
2021-12-10 21:39:54 +05:00
const embed = new Discord.MessageEmbed()
.setDescription(text)
.setColor(data.config.embed.color)
.setFooter(data.config.embed.footer);
2021-12-11 01:11:50 +05:00
2021-12-10 21:39:54 +05:00
message.channel.send(embed);
}
2021-12-11 01:11:50 +05:00
};
2021-12-10 21:39:54 +05:00
module.exports = Checkinvites;