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

embed-paginator

v2.0.1

Published

Paginate Message Embeds for Discord.JS library

Downloads

46

Readme

Embed Paginator

Discord message embeds that are cool, but paginated ones are even cooler. Presenting Embed Paginator which will help you code paginated embeds with nothing but just a few lines of code to configure how you want your embed to look!

Installation

npm install embed-paginator
or
yarn add embed-paginator

To contribute

  1. Fork this repo
  2. Clone your fork to your local machine
  3. CD into the project root directory
  4. Run npm install or yarn
  5. Create a new branch and make your contribution
  6. Make a pull request on GitHub for me to review

How To Use?

Feel free to play around and see what works for you! If you ever need anything that Embed Paginator does not provide, you can open an issue to request features or you can contribute and open a pull request!

const { PaginatedEmbed } = require('embed-paginator');

module.exports.execute = (client, message, args) => {
  const embed = new PaginatedEmbed({
    itemsPerPage: 2,
    paginationType: 'field',
    showFirstLastBtns: false
  })
    .setDescriptions(['This is my test embed.'])
    .setThumbnails([
      'https://i.pinimg.com/736x/85/7c/56/857c566baef4f1471f346ea13d0a5da0.jpg',
      'https://asset.vg247.com/genshin-impact-ayaka-build.jpg/BROK/thumbnail/1200x1200/quality/100/genshin-impact-ayaka-build.jpg'
    ])
    .setImages([
      'https://staticg.sportskeeda.com/editor/2022/03/a2277-16479754476161-1920.jpg',
      'https://d3fd5j8wprxn3h.cloudfront.net/wp-content/uploads/2021/07/kamisatoayaka-708x400.jpg'
    ])
    .setFields([
      { name: 'test', value: 'my awesome embed' },
      { name: 'foo', value: 'bar' },
      { name: 'hello', value: 'world' }
    ])
    .setFooters([{ text: 'Hello {page}' }, { text: 'Foo {page}' }])
    .setTitles(['First Title', 'Second Title'])
    .setAuthors([{ name: 'First Author', url: 'https://google.com' }, { name: 'Second Author' }])
    .setURLs(['https://discord.com'])
    .setTimestamp();

  await embed.send({ options: { channel: message.channel } });
};

module.exports.info = {
  name: 'foo'
};

Result

Change Log

2.0.1

This version is mainly for addressing language support

  • Add buttons to jump to first and last page
    • Can be disabled by setting showFirstLastBtns to false
    • Enabled by default
  • Add ability to customise pagination button text
    • To edit the label for each button, set in the constructor:
      • firstBtn - Label for button to jump to first page
      • prevBtn - Label for button to change to previous page
      • nextBtn - Label for button to change to next page
      • lastBtn - Label for button to jump to last page
  • Add {curPage} and {maxPage} variables in footer text
    • The {page} variable still exists (stays in English)
    • If no footer is set then {page} will take over
  • Add ability to use emoji
    • Disabled by default
  • Remove unused code for optimisation

2.0.0

  • Update Discord.JS from v12 to v14
  • Use buttons instead of reactions for pagination
  • Add interaction support
    embed.send({ options: { interaction, followUp: true, ephemeral: true } });
    • When an interaction is provided, it will be prioritised over a provided channel
    • Depending on the state of the interaction, you may use:
      • Follow up
      • Reply
      • Ephemeral
    • If followUp is not provided, the interaction will instead be reply
  • Add components support
    const row = new ActionRowBuilder().addComponents(new ButtonBuilder().setCustomId('test').setLabel('Test'));
    embed.send({ options: { channel: message.channel, components: [row] } });
    • Appended after the pagination buttons
  • Enable pagination on other attributes:
    • New attributes that can be paginated:
      • Titles
      • Authors
      • Footers
      • URLs
      • Thumbnails
      • Images
    • The newly enabled paginated attributes depend on the pagination of fields/descriptions
    • Provide only one item to the arrays for persisting data (same text/data across all pages)
  • Add editable footer support
    • If footer is not set, the embed pages will show
    • If footer is set, the embed pages will not show by default
      • Add {page} in the footer text in order to show embed pages as shown in the given example
  • Add toJSON() method

Author

Support Server

Support Server