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

@quantiom/pagemenu

v2.0.8

Published

Send dynamic discord embed menus, with pages controlled by reactions.

Downloads

42

Readme

#pageMenu With pageMenu, you can send "menus" on discord, which are controlled by reactions, thanks to Discord.JS. Example ##Install npm install @quantiom/pagemenu ##Usage

const Discord = require('discord.js');
const client = new Discord.Client();
const pageMenu = require('@quantiom/pagemenu');

client.on("message", (message) => {

  ...

  // new pageMenu(message, [pages], {options});

  let pMenu = new pageMenu(message,
  [   
      { 
          title: "title1", 
          description: "this is page 1", 
          function: function() { console.log("page 1"); }, // this function will be executed when the user goes to this page
          thumbnail: 'insert url here', 
          fields: [
            {
              name: "test",
              value: "field_desc",
              inline: true
            },
            {
              name: "test1",
              value: "field1_desc (not inline)",
              inline: false
            }
          ],
          color: "ffffff", // white
          url: "https://google.com",
          timestamp: true // sets the timestamp, *timestamp is not required, you don't have to do timestamp: false*.
      },
      { title: "title2", description: "this is page 2", function: function() { console.log("page 2"); }, image: 'insert url here'},
      { title: "title3", description: "this is page 3"}, // these are the only options required for a page
      { title: "title4", description: "this is page 4"} 
  ], /*options*/ {duration: 60000, expireFunction: function(msg) { msg.delete(); }}); 
  // the expire function will delete the page message once it's expired (based on duration)
  
  pMenu.getPage(0).setTitle("test"); // sets the title of page 0 (the first page) to "test"
  pMenu.pages[0].setTitle("test"); // same thing as above

  pMenu.getPage(1).addField("this is an inline field", "pretty cool", true); // adds an inline field to page 2
  pMenu.getPage(1).addField("this is a field", "epic"); // adds a non-inline field to page 2
  pMenu.getPage(1).setTimestamp(); // adds a timestamp to the page

  pMenu.addPages([{title: "blabla", description: "this is a description for the newly added page."}]).then(pages => console.log(pages));

  pMenu.run();

}

##Options

  • duration - how long the pagemenu will last in milliseconds, default 60000.
  • emojis - the emojis used to control the menu, they will do the same as the default ones.
  • waitingColor - the color while the reactions are being added, default is black.
  • waitingText - the text while the reactions are being added, default "Waiting..."
  • expireFunction(message) - this function will be called when the pagemenu duration has expired, by default, it will edit the message to "Page menu expired"

#Methods

  • run()

    Starts the pageMenu and other events.

  • getPage(index)

    Gets the page object from index (starts at 0 of course, 0 = page 1);

  • addPage(page)

    Adds a page to the menu.

  • addPages([pages])

    Adds multiple pages to the menu, pass an array of pages.

  • removePage(index)

    Removes a page from the menu with the index passed.

  • removePages([indices])

    Removes multiple pages, pass an array of indices.

  • swapPages(index1, index2)

    Swaps two pages.

  • reversePages()

    Reverses the order of the pages.

#Page Options

  • title required
  • description required
  • thumbnail
  • image
  • fields - an array of objects with name, value, and inline
  • timestamp - just set it to true (no need to set it to false because this is not required)
  • url
  • color

#Page Methods

  • setTitle(title)

  • setDescription(description)

  • setFunction(function)

    <page>.setFunction(function(){
        console.log("hello!")
    });
  • setThumbnail(URL or file path)

  • setImage(URL or file path)

  • addField(name, value, inline = false)

  • addBlankField(inline = false)

  • setTimestamp()

  • setURL(url)

    <page>.setURL("https://youtube.com");

  • setColor(color)

    <page>.setColor("fffff");