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

discordjs-paginator

v1.0.3

Published

Easy and lite discordjs embed paginator to apply directly to your bot

Downloads

9

Readme

Embed Paginator to use easy and fastly with discord.js

Install

# NPM
$ npm install discordjs-paginator
# Yarn
$ yarn add discordjs-paginator

Options

EmbedPaginator

| Option | Type | Required | Default | Description | |------------------|-------------------------------------------------------------------------------------|----------|-----------------------------------------------|----------------------------------------------------------------------| | message | Message | O | | The message instance to be binded with paginator | | bindPageViewTo | string (only "footer" and "author" allowed) | x | void | Location to bind page view like Page: 1 / 3 | | channel | TextChannel | x | void | Overrides the message option | | emojis.prev | string | x | ◀ | The emoji used for previous button | | emojis.stop | string | x | ⏹ | The emoji used for stop button | | emojis.next | string | x | ▶ | The emoji used for next button | | filterCallback | function: boolean | x | (r, u, e) => r.emoji.name === e && !u.bot | Callback function to filter reactions | | time | number | x | 360000 | Timeout to destroy reaction collectors | | pageView | string | x | "Page: {CURRENT_PAGE} / {TOTAL_PAGE}" | Page view text to be binded (only work with bindPageViewTo option) |

Usage

If you want to see usage more quickly, click

const { EmbedPaginator } = require("discordjs-paginator")
const { Client, Collection, MessageEmbed } = require("discord.js")
const client = new Client()
const PREFIX = "!"

client.storage = new Collection()
client.deploys = new Collection()

client.on("ready", () => console.log(`Ready as ${client.user.tag}`))

client.on("message", async message => {
    if (
        message.author.bot
        || message.channel.type === "dm"
        || message.system
        || !message.content.startsWith(PREFIX)
    ) return

    const args = message.content.slice(PREFIX.length).trim().split(/ +/gi)
    const command = args.shift().toLowerCase()

    if (command === "embed") {
        const subcommand = args.shift().toLowerCase()

        if (subcommand === "add") {
            const embed = new MessageEmbed().setDescription(args.join(" "))

            const cache = client.storage.get(message.author.id)
            if (cache) client.storage.set(message.author.id, [...cache, embed])
            else client.storage.set(message.author.id, [embed])

            return message.reply("added")
        }
        if (subcommand === "remove") {
            const index = parseInt(args[0]) - 1

            const cache = client.storage.get(message.author.id)
            if (!cache) return message.reply("couldn't find embed to remove, empty storage")
            if (!cache[index]) return message.reply(`index ${index} out of range(length: ${cache.length})`)

            client.storage.set(message.author.id, cache.filter((f, i) => i !== index))
            return message.reply("removed")
        }
        if (subcommand === "deploy") {
            const cache = client.storage.get(message.author.id)
            const msgResolvable = args[0]

            if (!cache) return message.reply("couldn't find embeds to show")
            if (!msgResolvable) return message.reply(`Usage: \`\`${PREFIX}embed deploy <msg ID>\`\``)

            const deploy = new EmbedPaginator({
                message: await message.channel.messages.fetch(msgResolvable),
                bindPageViewTo: "footer",
                pageView: "Page {CURRENT_PAGE} of {TOTAL_PAGE}"
            })

            for (const embed of cache) deploy.addEmbed(embed)

            deploy.show()

            client.deploys.set(message.author.id, deploy)
            return message.reply("deployed")
        }
        if (subcommand === "clear") {
            client.storage.delete(message.author.id)
            client.deploys.delete(message.author.id)
            return message.reply("forcibly removed embed storage")
        }
    }
})

client.login("super secret token")

Quick Usage

new EmbedPaginator({
  message: await message.channel.messages.fetch(msgResolvable),
  bindPageViewTo: "footer",
  pageView: "Page {CURRENT_PAGE} of {TOTAL_PAGE}"
})

Author

👤 zero734kr

🤝 Contribuiting

Issues and Pull Requests are welcome! If you had a problem please contact at issues page Code Change Requests are available to open pulls at PR page.

Support

If this library was useful please star⭐️ this repo

📝 License

Copyright © 2020 zero734kr. This project is MIT licensed.


This README was generated with ❤️ by readme-md-generator