discord-invites-tracker
v1.1.2
Published
A simple library to track invites
Downloads
62
Maintainers
Readme
About
discord-invites-tracker is a simple Node.js module that allows you to easily track invites of a guild
Installation
npm install discord-invites-tracker
# or
yarn add discord-invites-tracker
Example
const { Client, Intents } = require("discord.js");
const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_INVITES]
});
const invitesTracker = require("discord-invites-tracker");
const tracker = new invitesTracker(client, {
mongourl: 'YOUR MONGODB CONNECTION STRING' // optional
});
client.on('ready', () => {
console.log(`${client.user.username} is ready!`);
});
client.on('messageCreate', async (message) => {
if (message.author.bot || !message.guild || message.webhookId) return;
if (message.content.startsWith('!invites')) {
let invites = await invitesTracker.getInvites(message.author, message.guild);
message.reply(`${message.author} has ${invites} invites`);
};
});
tracker.on("guildMemberAdd", (member) => {
const welcomeChannel = member.guild.channels.cache.get("YOUR WELCOME CHANNEL ID HERE");
if (!member.inviter) return welcomeChannel.send(`I'm unable to track who invited ${member}`);
else return welcomeChannel.send(`Welcome ${member}! Invited by ${member.inviter} (${member.invites} invites)`);
});
client.login("YOUR BOT TOKEN HERE");
Help
Join my discord server for support regarding this module