npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

discord-inviter

v0.9.3

Published

check inviter when member join guild (work with vanity url & bots), top invites, member invites

Downloads

2,258

Readme

Discord-inviter

Installation

Install discord-inviter

$ npm install discord-inviter

Install discord.js

$ npm install discord.js

Features

  • Simple & easy to use 🎗️
  • Support vanity urls 🔗
  • Returns full object with invite & inviter data 📡

What's new ?

  • fix some bugs ⛏️
  • You can get inviter guild member (inviter.member) 📢
  • Support discord.js v12 & v13 & v14 ⚙️
  • Now, you can know when the invite is vanity or no (invite.isVanity) ✨

Getting Started

At first install the discord-inviter package

  • the exampls below are for discord.js (v13), you can update to (v14) without any problem (but don't forget to add the required intents).
const { Client, Intents } = require("discord.js"); // npm i discord.js
const client = new Client({
  intents: [
    Intents.FLAGS.GUILDS,
    Intents.FLAGS.GUILD_MESSAGES,
    Intents.FLAGS.GUILD_MEMBERS,
    Intents.FLAGS.GUILD_INVITES,
  ],
});

var { inviteTracker } = require("discord-inviter"), // npm i discord-inviter
  tracker = new inviteTracker(client);

client.on("ready", () => console.log("Bot Ready"));

// "guildMemberAdd"  event to get full invite data
tracker.on("guildMemberAdd", async (member, inviter, invite, error) => {
  // return when get error
  if (error) return console.error(error);
  // get the channel
  let channel = member.guild.channels.cache.get("939210311276306455"),
    Msg = `Welcome ${member.user}, invited by <@!${inviter.id}>, code ${invite.code}, invite count ${invite.count}`;
  // change welcome message when the member is bot
  if (member.user.bot)
    Msg = `Welcome ${member.user}, invited by <@!${inviter.id}>`;
  // send welcome message
  channel.send(Msg);
});

// "error" event to get any error
tracker.on("error", (guild, err) => {
  console.error(guild?.name, err);
});

client.on("messageCreate", async (message) => {
  // get member invites count
  if (message.content == "invites") {
    var invite = await inviteTracker.getMemberInvites(message.member);
    message.channel.send(
      `${message.author.tag} has ${invite.count} invite(s).`
    );
    // get server top invites
  } else if (message.content == "top-invites") {
    var top = await inviteTracker.getTopInvites(message.guild);
    message.channel.send(
      top
        .map((i, n) => `\`#${n + 1}\`- **${i.user.tag}** has __${i.count}__`)
        .join("\n")
    );
    // get info of any invite code
  } else if (message.content == "invite-info") {
    var invite = await inviteTracker.getInfo(client, "https://discord.gg/maxSPHjvaw"); // invite url or code
    if (!invite) return;

    message.channel.send(
      `Guild: ${invite.guild.name},\nInviter: ${
        invite?.inviter ? `${invite.inviter.tag}` : "Owner"
      },\nLink: ${invite.url}`
    );
  }
});

Notes:

  • You must use nodeJs version 16 or higher.
  • You need to update your nodeJs version if you use discord.js v12.

for replit

  • Go to shell and type npm i node@16
  • create file named .replit and type run = "npx node index.js"
  • Run the project.

Thanks for using it ❤️. Support