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

erela-discord

v2.0.3

Published

A oauth2 discord helper library

Downloads

25

Readme

npm npm downloads NPM version Open Source Love dependencies Status NPM

Erela Discord

A simple and easy to use oauth2 discord helper.

Installation

# Using yarn
yarn add erela-discord

# Using npm
npm install erela-discord

Methods

Client

const { ErelaClient } = require("erela-discord");

const options = {
  clientID: "12345678910", // Client ID, that's pretty obvious
  redirectUri: "http://localhost/8080/auth", // Set it on https://discordapp.com/developers/applications/bot_id/oauth2
  scope: ["guilds, identify"], // Default to "guilds identify", no need to use this option if you're not changing it
  clientSecret: "Bot Client Secret", // Your bot client secret
};

const Connection = new ErelaClient(options);

authURL()

const { ErelaClient } = require("erela-discord");

const Connection = new ErelaClient("options");

const authURL = Connection.authURL(); // Will return the oauth2 connection url

requestToken(access_token)

access_token: OAuth token

const { ErelaClient } = require("erela-discord");

const Connection = new ErelaClient("options");

const access_token = "2qRZcUqUa9816RVnnEKRpzOL2CvHBgF";

Connection.requestToken(access_token).then(console.log);

// If the request was succesful
/*
    {
      "access_token": "6qrZcUqja7812RVdnEKjpzOL4CvHBFG",
      "token_type": "Bearer",
      "expires_in": 604800,
      "refresh_token": "D43f5y0ahjqew82jZ4NViEr2YafMKhue",
      "scope": "identify guilds"
    }
*/

getUser(access_token)

access_token: Acess token, get one by requestToken()

const { ErelaClient } = require("erela-discord");

const Connection = new ErelaClient("options");

const { access_token } = Connection.requestToken(
  "6qrZcUqja7812RVdnEKjpzOL4CvHBFG"
);

Connection.getUser(access_token).then(console.log);

/*
  {
    username: '1868 Loliticos',
    locale: 'pt-BR',
    mfa_enabled: false,
    flags: 128,
    avatar: '8342729096ea3675442027381ff50dfe',
    discriminator: '1868',
    id: '532294395655880705'
  }
*/

getUserGuilds(access_token)

access_token: Access token, get one by requestToken()

const { ErelaClient } = require("erela-discord");

const Connection = new ErelaClient("options");

const { access_token } = Connection.requestToken(
  "2qRZcUqUa9816RVnnEKRpzOL2CvHBgF"
);

Connection.getUserGuilds(access_token).then(console.log);

/*
  {
    "id": "674295547024244767",
    "name": "1868 Loliticos",
    "icon": "8342729096ea3675442027381ff50dfe",
    "owner": true,
    "permissions": 36953089
  }
*/

getUserConnections(access_token)

access_token: Authentication token, get one by requestToken()

const { ErelaClient } = require("erela-discord");

const Connection = new ErelaClient("options");

const { access_token } = Connection.requestToken(
  "2qRZcUqUa9816RVnnEKRpzOL2CvHBgF"
);

Connection.getUserConnections(access_token).then(console.log);

/*
  {
    [
      {
        verified: true,
        name: 'epicusername',
        show_activity: true,
        friend_sync: false,
        type: 'twitch',
        id: '31244565',
        visibility: 1
      }
    ]
  }
*/