invite-tracker-discord
v1.0.2
Published
to tracking discord invites
Downloads
1
Maintainers
Readme
invite-tracker-discord is a module to track discord invites
discord inviter tracker has a database which created locally and it used to track the invite activity of discord user.
Features
- message to channel when member invite another member
- message to channel when a member left the channel
- leaderboard
Installation
discord inviter tracker requires Node.js v16+ to run.
npm i invite-tracker-discord
DOCS
for starting you will need to require the module
let InviteTrack = require('invite-tracker-discord')
then you will need to send the client for the module
InviteTrack(client)
/inviteboard discord command will reply the invites leaderboard
examples:
require("dotenv").config();
const InviteTrack = require('invite-tracker-discord')
const Database = require("easy-json-database");
const db = new Database("./db.json")
let discord = require('discord.js')
let client = new discord.Client({ intents: [Object.values(discord.Intents.FLAGS).reduce((acc, p) => acc | p, 0)], partials: ["REACTION"] })
InviteTrack(client);
client.on('messageCreate', async (message) => {
let invitesCount = db.get('invitesCount');
var sorted = {}
if (message.content === '/inviteboard') {
if (Object.keys(invitesCount).length > 1) {
Object.keys(invitesCount).sort((a, b) => invitesCount[b] - invitesCount[a]).map(item => sorted[item] = invitesCount[item]);
let leaderboard = "";
Object.keys(sorted).forEach(async (inviteId, index) => {
leaderboard += `*${index + 1}. <@${inviteId}> with invites **${sorted[inviteId]}***\n`
})
message.channel.send(leaderboard);
}
else {
let leaderboard = "";
Object.keys(invitesCount).forEach(async (inviteId, index) => {
leaderboard += `*${index + 1}. <@${inviteId}> with invites **${invitesCount[inviteId]}***\n`
})
message.channel.send(leaderboard);
}
}
});
client.login(token);