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

@ashuinsideout/discord.js-utils

v6.1.0

Published

A utils package for discord.js lib.

Downloads

9

Readme

Discord.js Utils (Re-Coded in TypeScript)

banner

A utils package for discord.js lib. This contains utils function and classes to easily work with Discord.js

Support

Join our Discord Server for any support related queries.

Installation

npm i @ashuinsideout/discord.js-utils or yarn add @ashuinsideout/discord.js-utils

Initialization

const discordUtils = require('@ashuinsideout/discord.js-utils');
const { Client } = require('discord.js');
const client = new Client();
discordUtils.init(client, {
  isCmdManager: true,
  isHelpCommand: true,
  cmdManagerOptions: { prefix, isPrefixMap: false },
});
client.login(token);

Options

| Option | Default | Description | | ----------------- | ------------------------------------ | ----------------------- | | isCmdManager | false | Enables command manager | | isHelpCommand | false | Adds a help command | | cmdManagerOptions | { isPrefixMap: false, prefix: '!'} | Command Manager Options |

Features

| Function / Class | Description | | ------------------------------------- | -------------------------------------------------------------------------------------------------- | | MessageQuestion | Builds message question object | | ReactionQuestion | Builds reaction question object | | QuestionsAPI | Build the questions API. Lets you easily ask long sets of questions from single or multiple users. | | askReactionQuestion | Lets your ask a single reaction question | | askMessageQuestion | Lets your ask a single message question | | ReactionMenu | Builds a reaction menu (Credits: Juby210) | | PaginationMenu | Builds a pagination menu (Credits: Thomas Jowsey) | | errorHandler | One liner error handler | | deepCloneWithLose | Deep clones a non-complex object | | isValidSnowflake | If the provide string is a valid snowflake | | fetchUser | Fetches a user | | fetchChannel | Fetches a channel | | fetchGuild | Fetches a guild | | fetchMember | Fetches a member | | fetchRole | Fetches a role | | toTimestamp | Converts string time eg: 5h2m into milliseconds | | toTimeLeft | Converts milliseconds to 1 Minute 20 Seconds format | | getRandomInt | A random number between the provided range | | findCodeBlock | Finds the groups between a string code block | | findEmoteById | Finds a emote by id | | isValidEmail | Checks if an email address is valid | | getConfig | Creates a config file or yml or json and returns the config object | | SpamHandler | Checks if a user is spamming | | getPrefix | Gets the default prefix or guild prefix | | getPrefixMap | Gets the guild prefix map | | registerCategory | Registers a category | | addCommand | Adds a command | | addMiddleware | Adds a middleware |

Examples

QuestionsAPI Example

const {
  addCommand,
  MessageQuestion,
  ReactionQuestion,
  QuestionsAPI,
} = require('@ashuinsideout/discord.js-utils');
const { MessageEmbed } = require('discord.js');

module.exports = async () => {
  addCommand({
    command: 'helpme',
    handler: async (message) => {
      const typeEmbed = new MessageEmbed({
        description: `What type of help you want?
            ❤: *Love Life*
            💰: *Money*`,
        color: 'RANDOM',
      });
      const moreInfo = new MessageEmbed({
        description: 'We need additional about your situation',
        color: 'RANDOM',
      });
      const api = new QuestionsAPI();
      const typeQuestion = new ReactionQuestion(message.author.id)
        .setQuestion({ embed: typeEmbed, reply: message.author })
        .setPossibleAnswers(['❤', '💰'])
        .setRun(({ reaction }) => {
          if (reaction.emoji.name === '❤') return 'Love';
          return 'Money';
        });
      const helpQuestion = new MessageQuestion(message.author.id)
        .setQuestion({ embed: moreInfo, reply: message.author })
        .setRun(({ message }) => message.content);
      api.addQuestion([typeQuestion, helpQuestion]);
      const { data } = await api.ask(message.channel);
      const type = data[0].result;
      const info = data[1].result;
      const embed = new MessageEmbed({
        description: `${message.author.toString()} needs help with **${type}**
            *Here is some additional information:*
            ${info}`,
      });
      message.channel.send({ embed });
    },
  });
};

Terms and Conditions

This Repository only available for code look up and personal use.

You are not allowed to steal the code from this repository.