# @androz2091/discord-invites-tracker

> Track the invites in your servers to know who invited who and with which invite!

Latest version **1.2.3** (published 2022-11-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install @androz2091/discord-invites-tracker
pnpm add @androz2091/discord-invites-tracker
yarn add @androz2091/discord-invites-tracker
bun add @androz2091/discord-invites-tracker
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.3 |
| Published | 2022-11-10 |
| First published | 2021-07-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 26.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Androz2091 |
| Maintainers | androz2091 |

## Links

- npm: https://www.npmjs.com/package/@androz2091/discord-invites-tracker
- npm.io page: https://npm.io/package/@androz2091/discord-invites-tracker

## Recent versions

- 1.2.3 (latest) — 2022-11-10
- 1.2.2 — 2022-11-10
- 1.1.1 — 2022-06-23
- 1.1.0 — 2021-11-19
- 1.0.0 — 2021-11-19
- 0.1.4 — 2021-11-18
- 0.1.2 — 2021-07-30
- 0.1.1 — 2021-07-30

## README

# [Discord Invites Tracker](https://npmjs.com/@androz2091/discord-invites-tracker)

Track the invites in your servers to know who invited who and with which invite!

## Installation

```sh
npm install @androz2091/discord-invites-tracker
# or
yarn add @androz2091/discord-invites-tracker
```

## Example

```js
const Discord = require('discord.js');
const client = new Discord.Client({
    intents: [Discord.GatewayIntentBits.Guilds]
});

const InvitesTracker = require('@androz2091/discord-invites-tracker');
const tracker = InvitesTracker.init(client, {
    fetchGuilds: true,
    fetchVanity: true,
    fetchAuditLogs: true
});

tracker.on('guildMemberAdd', (member, type, invite) => {

    const welcomeChannel = member.guild.channels.cache.find((ch) => ch.name === 'welcome');

    if(type === 'normal'){
        welcomeChannel.send(`Welcome ${member}! You were invited by ${invite.inviter.username}!`);
    }

    else if(type === 'vanity'){
        welcomeChannel.send(`Welcome ${member}! You joined using a custom invite!`);
    }

    else if(type === 'permissions'){
        welcomeChannel.send(`Welcome ${member}! I can't figure out how you joined because I don't have the "Manage Server" permission!`);
    }

    else if(type === 'unknown'){
        welcomeChannel.send(`Welcome ${member}! I can't figure out how you joined the server...`);
    }

});

client.login(process.env.TOKEN);
```

**Different join types available:**

* `normal` - When a member joins using an invite and the package knows who invited the member (`invite` is available).
* `vanity` - When a member joins using an invite with a custom URL (for example https://discord.gg/discord-api).
* `permissions` - When a member joins but the bot doesn't have the `MANAGE_GUILD` permission.
* `unknown` - When a member joins but the bot doesn't know how they joined.

## Ignoring guilds

```js
const InvitesTracker = require('@androz2091/discord-invites-tracker');
const tracker = InvitesTracker.init(client, {
    fetchGuilds: true,
    fetchVanity: true,
    fetchAuditLogs: true,

    // servers that contain "nude" in their name will not be processed
    exemptGuild: (guild) => guild.name.includes('nude')
});
```

---
_Source: https://npm.io/package/@androz2091/discord-invites-tracker · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
