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

easy-embed-pages

v0.0.3

Published

An awesome module for easy and 100% customizable dynamic embeds with interactive pages!

Downloads

4

Readme

EasyEmbedPages

A fully customizable and module for easy interactive discord embeds with dynamic pages!

This module is used to make hassle-free embeds with different pages... This module is fully customizable and each property of each page can be changed! The description of the embed gets dynamically carried over to a different page if it exceed 2000 characters

Note: works only with discord.js 12

Installation

npm i easy-embed-pages

Usage

const EasyEmbedPages = require('easy-embed-pages');

Examples

Basic simple usage

Note: Content greater than 2000 characters gets transferred to the next embed page!

const embed = new EasyEmbedPages(message.channel, {
    // Here you can add anything **except embed fields** that can be added in a regular discord embed in json format
    color: '#ff00ff',
    url:'https://example.com',
    title: "Simple Embed",
    description: "insert long text here"
});

embed.start(); // sends the embed in the specified channel and starts the interactive process

Using custom fields and other things for each page

Note: If you specify pages in pages which are more than the dynamic content pages, they will be added as extra pages!

const embed = new EasyEmbedPages(message.channel, {
    pages: [
        {
            fields: [
                {
                    name: "Custom field yay!",
                    value: "Yikes... I love this module!",
                    inline: false
                }
            ]
        },
        {
            title: "This page has a custom title!",
            description: "And a custom description field too!"
        }
    ],
    color: '#ff00ff',
    url: 'https://example.com',
    title: "Simple Embed",
    description: "insert long text here"
});

embed.start();

Using premade embeds

Note: You can use you premade Discord#MessageEmbed this way

/*
const myEmbed1 = new Discord.MessageEmbed();
const myEmbed2 = new Discord.MessageEmbed();
*/

const embed = new EasyEmbedPages(message.channel, {
    pages: [
        myEmbed1.toJSON(),
        myEmbed2.toJSON()
    ],
});

embed.start();

Advanced Usage

Full cranked up usage!

const embed = new EasyEmbedPages(message.channel, {
    //embed fields
    pages: [
        {
            title: "Hello World!",
            color: "#00ffff",
            author: {
                name: "Jaguar"
            }
        }, 
        {
            fields: [
                {
                    name: "My field",
                    value: "My value",
                    inline: true
                }
            ],
            thumbnail: "https://example.com/my_other_image.png"
        }
    ],
    color: 'RANDOM', // here you can fill any Discord Color, filling with RANDOM will give each page a random color
    url: "https://example.com",
    title: "This is a test embed",
    author: {
        name: "Jaguar"
    },
    footer: {
        text: "Insert Footer Text Here"
    },
    description: "Insert long text here",
    image: "https://example.com/your_large_image.png",
    thumbnail: "https://example.com/your_small_thumbnail.png",
    
    allowStop: true, // enable if you want the stop button to appear used to stop the interactive process
    time: 300000, // the idle time after which you want to stop the interactive process
    ratelimit: 1500 // ratelimit (in milliseconds) to prevent reaction spam, optional. (anything greater than 2 is not recommended)
},
(embed) => {
    // this function will codeblock the whole description!
    if(embed.description) embed.setDescription(`\`\`\`\n${embed.description}\n\`\`\``)
});

embed.start({
    channel: message.channel, // the channel in which you want to send the embed
    person: message.author    // use this if you only allow a specific person to control the reactions
});

Example Eval Command!

const EasyEmbedPages = require('easy-embed-pages');

async function run(client, message, args) {
    const clean = text => ((typeof text === "string") ? text.replace(/`/g, "`" + String.fromCharCode(8203)).replace(/@/g, "@" + String.fromCharCode(8203)) : text);

    let output;
    let status = true;
    try {
        let evaled = eval(args.join(' '));
        if (evaled instanceof Promise) evaled = await evaled;
        else if (typeof evaled !== "string") evaled = require("util").inspect(evaled);
        
        output = clean(evaled).replace(new RegExp(client.token, 'g'), '[TOKEN REMOVED]');
    } catch (err) {
        status = false;
        output = err.toString();
    }
    
    const embed = new EasyEmbedPages(
        message.channel,
        {   
            color: status ? 'GREEN' : 'RED',
            title: "Eval response",
            description: output
        },
        (embed) => {
            if(embed.description) embed.setDescription(`\`\`\`xl\n${embed.description}\n\`\`\``)
        }
    );
    embed.start({ user: message.author });
}