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-inv

v2.0.0

Published

Get more information about a discord invitation link!

Downloads

69

Readme

discord-inv

Features

  • New: TypeScript support
  • NPM package that gets information about an invite from the discord api
  • Useful for websites where users can input their invite-links
  • Useful for bots to detect invites which are not for this guild
  • Support for scheduled guild event querying in invites
  • Supports the Promise-API, so you can use .then, .catch and all the other stuff 😉

Install from NPM

$ npm i discord-inv --save

Usage

Get invite data by code

  • getInvite(code, withCounts = false, eventID) - Get information about an invite using the invite-code
    • Parameters
      • code (string): Code of the invite
      • withCounts (optional, boolean): approximate_member_count and approximate_presence_count are only going to be returned, if set to true (default = false)
      • eventID (optional, snowflake): Snowflake of an scheduled event. guild_scheduled_event will only be set, if this is valid.
    Returns: Promise<Invite>

Extract data from Invite-URL

  • getInviteDataFromURL(inviteURL) - Extracts the code & event-id from any discord invite url (won't call the Discord API)
    • Parameters
      • inviteURL (string): Full Discord-URL of an invite
    • Returns: Object
      • url: parsed URL
      • code: Extracted code of the invite
      • eventID (can be null): Extracted eventID of the invite

Get invite data by Invite-URL

  • getInviteFromURL(url, withCounts = false, eventID) - Get information about an invite using an invite-url. Basically combines getInviteDataFromURL and getInvite.
    • Parameters
      • url (string): Full Discord-URL of an invite
      • withCounts (optional, boolean): approximate_member_count and approximate_presence_count are only going to be returned, if set to true (default = false)
    Returns: Promise<Invite>

Invite-Class

Please see APIInvite for details about invites. We might add more props / functions later, but currently only the parameters listed there are available.

Examples

const discordInv = require('discord-inv');

const inviteurl = 'https://discord.com/invite/73JH6HT2?event=1026160493125189653';

discordInv.getInviteFromURL(inviteurl, true).then(invite => {
    console.log(invite)
}).catch(console.log('This is not a valid invite'))

/*
OUTPUT: 

Invite {
  code: 'hVv59YA9',
  type: 0,
  expires_at: '2022-10-09T18:24:06+00:00',
  guild: {
    id: '510432380209725441',
    name: 'Test2',
    splash: null,
    banner: null,
    description: null,
    icon: 'bc48e444cd9e5bf4a0e8ac25fb2fecc2',
    features: [
      'NEW_THREAD_PERMISSIONS',
      'NEWS',
      'COMMUNITY',
      'THREADS_ENABLED_TESTING',
      'INVITES_DISABLED',
      'THREADS_ENABLED',
      'TEXT_IN_VOICE_ENABLED'
    ],
    verification_level: 1,
    vanity_url_code: null,
    premium_subscription_count: 0,
    nsfw: false,
    nsfw_level: 0
  },
  channel: { id: '977631413484531723', name: 'lol', type: 2 },
  inviter: {
    id: '413429490342035466',
    username: 'SCDerox',
    avatar: '81681c7ea180ce648c25d35279b888b8',
    avatar_decoration: null,
    discriminator: '4645',
    public_flags: 64
  },
  approximate_member_count: 17,
  approximate_presence_count: 7,
  guild_scheduled_event: {
    id: '1026160493125189653',
    guild_id: '510432380209725441',
    channel_id: '977631413484531723',
    creator_id: '413429490342035466',
    name: 'test',
    description: null,
    image: null,
    scheduled_start_time: '2022-10-04T17:00:00+00:00',
    scheduled_end_time: null,
    privacy_level: 2,
    status: 1,
    entity_type: 2,
    entity_id: null,
    entity_metadata: null,
    sku_ids: [],
    user_count: 1
  }
}
*/

Migration from v1 to v2

Well, the whole module got reworked in v2, so bascially everything changes. We advise you to either continue using v1 or re-implementing all the parts using discord-inv.

Contributing

Feel free to create any issues and PRs in our github repository if you want to contribute.

© Simon Csaba, 2020-2022 | mail[at]scderox.de