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

modals-eris

v1.1.0

Published

Create Modals using the Discord API. Focused on Eris library.

Downloads

20

Readme

eris-modals

a npm package to create Modals using the Discord API. It's focused on Eris

Modals-eris is a package that allows you tu create modals in the best way with any Discord bot library (discord.js, eris,...) We are bringing support in TutoDiscord (https://discord.gg/9jPjxMB). Developed by dirquel (TutoDiscord)

Create Modal in Eris

const Eris = require('eris'); //import Eris
const bot = new Eris('discord_secret_token') //Create the client
const { createModal } = require('modals-eris') //Require the package

bot.on('interactionCreate', async (interaction) => { //calling interactionCreate event
    if(interaction.custom_id == 'display_modal') { //if interaction's ID is "display_modal"
        await createModal(interaction, {
            title: 'título_del_modal',
            custom_id: 'myModal', //to interact in the future with the modal you need to set this ID.
            components: [ //add the action row to contain all the text inputs.
                {
                    type: 1, // the type of the action row
                    components: [ // to add the text inputs
                        {
                            type: 4, // the text input type 
                            custom_id: 'another_custom_id', // you need this id in order to know what did the user write here.
                            label: 'this is just a label... LOL', // label_that_will_be_shown_at_the_top_of_the_placeHolder
                            style: 1 // 1 for short input, 2 for paragraph input.
                            min_length: 1 // this is not compulsory. The minimum length the answer must have. (between 0 and 4000)
                            max_length: 20 // this is not compulsory. The maximum length the answer must have. (between 1 and 4000)
                            required: true // this is not compulsory. Boolean. If it's compulsory to answer this question before sending the modal or not.
                            value: 'hellooo' // this is not compulsory. Pre-filled value for this component (max 4000 characters)
                            placeholder: 'write something here' // this is not compulsory. Custom placeholder text if the input is empty (max 100 characters)
                        }
                    ]
                }
            ]
        })

        //////////////////////////////////////////////////////////////////////////////////////
        let Modal = {
            // Modal options
        }
        
        await createModal(interaction, Modal)
        //////////////////////////////////////////////////////////////////////////////////////
    }
})

bot.connect() //connect the bot to Discord.

Crear Modal Discord.js:

const Discord = require('discord.js');
const client = new Discord.Client({  });
const { createModal } = require('modals-eris');

client.on('interactionCreate', async (interaction) => { //los Modales solo se pueden crear a partir de interacciones (botones, selectMenus, etc.)
    if(interaction.isButton()) { //si un usuario interactúa con un botón es un botón
        await createModal(interaction, {
            title: 'título_del_modal',
            custom_id: 'myModal', //para poder interactuar más adelante con el Modal, necesitas añadirle una ID.
            components: [ //añades los placeholder, es decir, las líneas en las que el usuario podrá escribir dentro del modal.
                {
                    type: 1,
                    components: [
                        {
                            type: 4,
                            custom_id: 'another_custom_id',
                            label: 'etiqueta que saldrá encima del placeHolder.', //otra ID, esta vez para interacctuar con el placeHolder o línea de texto que estás creando en el Modal.
                            style: 1 //indicas que es un text input
                            min_length: 1 // no obligatorio. El número mínimo de caracteres que la respuesta debe tener. (entre 0 y 4000)
                            max_length: 20 // no obligatorio. El número máximo de caracteres que la respuesta debe tener. (entre 1 y 4000)
                            required: true // no obligatorio. Booleano. Si es obligatorio responder esta pregunta antes de enviar el Modal
                            value: 'holaaaa' // no obligatorio. Valor pre-escrito en este componente (max 4000 characters)
                            placeholder: 'escribe algo aquí' // no obligatorio. Placeholder predeterminado para este componente si el texto está vacío (máximo 100 caracteres)
                        }
                    ]
                }
            ]
        })
        ////////////////////////////////////////////////////////////////////////////////////
        let Modal = {
            //opciones
        };

        await createModal(interaction, Modal);
        ////////////////////////////////////////////////////////////////////////////////////
    }
})

client.login('discord_secret_token') //Conectar el bot a Discord.