azury-invites
v2.0.1
Published
Downloads
5
Readme
Azury Invite Tracker 🔥
How to install?
$ npm install azury-invites
What does it do?
- Tracks discord invites
- Supports discord vanity urls. Ex
discord.gg/azury
- Returns full object with invite data
How to use it in code?
/* ---~~~---~~~---~~~--- Example code provided by azury ---~~~---~~~---~~~--- */
const { Client, Intents } = require("discord.js"); // Install discord's package
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MEMBERS,
Intents.FLAGS.GUILD_INVITES,
],
});
var { inviteTracker } = require("azury-invites"); // Install our package
var tracker = new inviteTracker(client);
client.on("ready", () => {
console.log(`The bot ${client.user.tag} is now up and running!`)
});
tracker.on("guildMemberAdd", async (member, inviter, invite, error) => {
if(error) return console.error(error);
const channel = member.guild.channels.cache.get("channel-id")
channel.send(`Welcome ${member.user}, invited by ${inviter.target}, code ${invite.code}, invite count ${invite.count}`);
if (member.user.bot) channel.send(`Welcome ${member.user}, invited by <@!${inviter.id}>`);
});
/* -~~- If an error is received, send a log -~~- */
tracker.on("error", (guild, err) => {
console.error(guild?.name, err);
});
/* -~~- -~~- -~~- -~~- -~~- */
client.on("messageCreate", async (message) => {
if (message.content == "invites") {
var invite = await inviteTracker.getMemberInvites(message.member);
message.channel.send(`📊 ${message.author.tag} has ${invite.count} invite(s).`);
} else if (message.content == "top-invites") {
var top = await inviteTracker.getTopInvites(message.guild);
message.channel.send(`📊 **__Top Invites of ${message.guild.name}__**`+ top.map((i, n) => `\`#${n + 1}\`- **${i.user.tag}** has __${i.count}__`).join("\n"));
} else if (message.content == "invite-info") {
var invite = await inviteTracker.getInfo(client, "invite-code"); // info about a invite code
if (!invite) return;
message.channel.send(`Guild: ${invite.guild.name},\nInviter: ${invite?.inviter ? `${invite.inviter.tag}` : "**Vanity**" },\nLink: ${invite.url}`
);
}
});