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

@jdaniel-dev/utils.js

v1.12.8

Published

Este Package fue hecho para facilitar todo lo relacionado con el desarrollo de bots de discord, con un util ya hecho para quien guste

Downloads

48

Readme

- Sobre

Este Package fue hecho para facilitar todo lo relacionado con el desarrollo de bots de discord, con un util ya hecho para quien guste Base del utils sacado de Tohru

- Instalando el Package

npm i @jdaniel-dev/utils.js
yarn add @jdaniel-dev/utils.js

- Utilizando el Package

const JDaniel_Util = require('@jdaniel-dev/utils.js')
const util = new JDaniel_Util()
/**
Para Setearlo en el client es solo:
client.util = new JDaniel_Util()
**/

- Command Handler

Depende de como lo definiste pero este sería un ejemplo

const JDaniel_Util = require('@jdaniel-dev/utils.js') //Llamamos el Paquete
const util = new JDaniel_Util() //Creas una nueva istancia del Paquete

client.comandos = new Discord.Collection()  //Creas el Map Collection donde se guardaran los comandos
util.loadCommands(client,'comandos')  //Cargas todos los comandos en la carpeta 'comandos'

Tambien te puede dar un error, ya que en el index.js no tienes definido los comandos, si es que si, debes cambiarlo a comandos, Ejemplo:

//[Correcto]
client.comandos = new Discord.Collection()
//[Incorrecto]
client.commands = new Discord.Collection()
client.cmd = new Discord.Collection()

- Bot de Ejemplo (Sin Command handler)

const Discord = require('discord.js'); //Llamamos el paquete de discord
const client = new Discord.Client({
    intents: 32511
}) //Creas el cliente de discord
const JDaniel_Util = require('@jdaniel-dev/utils.js')
const util = new JDaniel_Util(client)

client.on('ready', () => {
    console.log('Bot Inicializado')
});

client.on('message', async(message) => {
    if(message.author.bot || message.channel.type === 'dm') return;
    const prefix = '!'
    if(message.content.toLowerCase() === 'hola'){
        message.channel.send(`Hola <@${message.author.id}>`)
    }
    if(!message.content.startsWith(prefix)) return;
    cons args = util.argsIfy(message)
    if(message.content.toLowerCase().slice(prefix.length) === 'ping') {
       message.channel.send(`Pong! ${client.ws.ping}ms`)
    }
    if(message.content.toLowerCase().slice(prefix.length) === 'random') {
        message.channel.send(`Numero al azar entre el 0 y 9: ${util.random(0, 9)}`)
    }
    if(message.content.toLowerCase().slice(prefix.length) === 'status') {
        message.channel.send(`CPU: ${util.cpuUsage()}% \nRAM: ${util.ramUsage()}`)
    }
    if(message.content.toLowerCase().slice(prefix.length) === 'say') {
        if(!args) return message.channel.send('Escribe el texto que quieres que diga!')
        message.channel.send(args.join(' '))
    }
    if(message.content.toLowerCase().slice(prefix.length) === 'rei') {
        message.channel.send(util.rei())
    }
});

client.login('token');//El token se consigue en el Developers Portal

- Bot de Ejemplo (Con Command Handler)

const Discord = require('discord.js');
const client = new Discord.Client({
    intents: 32511
})
const JDaniel_Util = require('@jdaniel-dev/utils.js')
const util = new JDaniel_Util(client)

client.comandos = new Discord.Collection()
util.loadCommands(client,'comandos')

client.on('ready', () => {
    console.log('Bot Inicializado')
});

client.on('message', async(message) => {
    if(message.author.bot || message.channel.type === 'dm') return;
    const prefix = '!'
    if(!prefix.some(p => message.content.startsWith(p))) return;
    const args = message.content.slice(prefix.length).trim().split(/ +/)
    const commandName = args.shift().toLowerCase()
    const command = client.comandos.get(commandName) || client.comandos.find(cmd => cmd.aliases && cmd.aliases.includes(commandName))
    const JDaniel_Util = require('@jdaniel-dev/utils.js')
    const util = new JDaniel_Util(client)
    if(!command) return;
    const d = {
      message,
      client,
      args,
      util
    };
    try {
      command.execute(d)
    } catch (e) {
      console.log(e)
    }
});

client.login('token');//El token se consigue en el Developers Portal

- Base de Comando (Del Handler)

const { Discord, MessageEmbed, MessageAttachment } = require('discord.js')

module.exports = {
  name: "", //Nombre de Tu comando
  aliases: [], //Alias de tu comandos (Este es en Array)
  async execute(d){
    //Aquí el codigo, si se evalua d, este retornara args, client y message
  }
}

- Crear Funciones Personalizadas

<util>.create(/*Nombre de la Función*/, /*Lo que retornara*/)
  • Ejemplo:
<util>.create('fakeIP', () => {
  function random(min, max){
    Math.floor(Math.random() * (max - min)) + min
  }
  return `${random(0,250)}.${random(0,250)}.${random(0,250)}.${random(0,250)}`
})

- Function Handler

Para cargar una función desde una carpeta dada debe ser así:

<util>.loadFunctions(Directorio)
  • Ejemplo:
<util>.loadFunction('Custom')

(./Custom/test.js)

module.exports = {
  name: 'test',
  test(params){
    console.log(`Testeo! ${params}`)
  }
}

- Funciones

<util>.update()
<util>.reboot()
async <util>.eval('Codigo')
<util>.execute('Comando')
<util>.random(min, max)
<util>.randomText(['array1', 'array2'...], 1)
<util>.randomString(length)
<util>.ramUsage()
<util>.cpuUsage()
async <util>.loadCommands(client,'comandos')
async <util>.getMember(message, d.args)
async <util>.getUser(message, d.args)
<util>.meme()
async <util>.fetch(URL)
<util>.argsIfy(message)
<util>.rei()
<util>.error(message, error)
<util>.has(array, message)
<util>.allMembersCount(client)
async <util>.rule34(busqueda)
<util>.math(operación)
<util>.isHex(Color en Hexadecimal)
<util>.isSnowflake(ID)
<util>.isBanned(Usuario (El Objeto de un usuario de discord), Servidor (El Objeto de un servidor de discord))
async <util>.isVoted(Usuario (El Objeto de un usuario de discord), Token de Top.gg)
<util>.getWebhook(URL (URL del Webhook)) //Funciona similar a un canal (https://discord.js.org/#/docs/discord.js/stable/class/WebhookClient)
<util>.getSource(Función)
<util>.fakeHack(username)

- Enlaces

Soporte (El Servidor es de Soporte de Tohru, pero sera también Utilizado para Soporte de este package)

Portal de Desarrolladores

Github