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

dbd.js-utils

v0.1.1

Published

A simple Utility that will help dbd.js users develop their bot

Downloads

61

Readme

dbd.js-utils

An extra Utility that will develop dbd.js bots more easier

What does it do?

  • Formatting Dates
  • Progress Bars for Music and Others
  • ms-parser and parse-ms in one
  • Timeago Possibility
  • Convert to Music Duration Format
  • DBD.JS Command Handling && Reloading
  • Extended JavaScript Map options (Collection)

Methods

  • parseToMS(string) - Convert Duration in String to MS (Same as ms-parser)

Example

.parseToMS("3d10m3M") // can be declared as 3 Months, 3 days, 10 Minutes
  • parseMS(ms) - Convert MS to Durations (seconds, minutes, hours, days, months, years) (More possibilities than parse-ms)

Example

.parseMS(345840000) // 3 and 1 Days, 4 minutes 

Output

{
  second:0,
  minute:4,
  hour:0,
  day:4,
  month:0,
  year:0
}
  • progressBar(SubstractSeconds, maxSeconds, AmountOfBars, addMarker, FilledSymbol, UnfilledSymbol) - Creates a Progress bar based on given data

Logic of command

maxSeconds will be divided by AmountOfBars to create the divider, then SubstractSeconds will subtract maxSeconds and will be divided by divider, the results will create a Filled Bar marked with FilledSymbol, if addMarker is given, it will add it to the end of Filled Bar, then the amount of Filled Bar will substract AmountOfBars to get the Unfilled bars that will be filled with UnfilledSymbol.

Example

.progressBar(102, 315, 10, "📀", "―", "―")

Output

――――📀―――――
  • formatDate(datestamp / date in ms, format, timezone) - Convert datestamp to Date and Format it

Example

.formatDate(1613374163494, "day, dd mmm yyyy", "UTC")

Output

Monday, 15 Feb 2021

List of Formats

| Format | Description | Output | | ------------- |:-------------:| -----| | YYYY | Gets the Full Year of date | 2021 | | YY | Gets the last 2 digits of Full Year | 21 | | DDD | Gets the Abbreviation of Day of the Week | Mon | | DAY | Gets the Name of Day of the Week | Monday | | DD | Gets the Day Date in Month of date | 15 | | D | Gets the Number Day of the Week | 2| | MMM | Gets the Month Abbreviation | Feb | | MONTH | Gets the Month Name of date | February | | MM | Gets the Month of date | 2 | | HOUR | Gets the Amount of Hour of date | 7 | | MIN | Gets the Amount of Minutes of date | 37 | | SEC | Gets the Amount of Seconds of date | 37 |

  • toMusicDuration(ms) - Convert Milliseconds to Music Duration Format (hour:min:sec)

Example

.toMusicDuration(288000)

Output

4:48
  • (class) Collection(Iterable) - Creates an extended Map API with extra methods/functions

Example

const dbdUtil = require("dbd.js-utils")
const Collection = new dbdUtil.Collection()

You can use Object or Array to create a Starting Data (Keys and Values)

new dbdUtil.Collection([["User", "Kino"], ["myId", 123]]) // Array

new dbdUtil.Collection({User:"Kino", myId:123}) // Object
  • (class) CommandHandler() - Creates a class that handles commands

Example

const bot = new dbd.Bot({
  //DBD.JS Options
})
const CommandHandler = new dbdUtil.CommandHandler(bot)
CommandHandler.handle("./commands") // ./commands is a path

Can't see a possibility to reload commands? Wrong, you can!

We added an extra property for you to use the CommandHandler

client.CommandHandler

Reloading commands

$djsEval[

  //Reloading the Commands (path will be automatic if you have used it (Not recommended!))
  client.CommandHandler.handle()
  //with Path
  client.CommandHandler.handle("./commands")
  //or if something went wrong
  client.CommandHandler.handle(`${process.cwd()}/commands`)
]

This can also change bot.loadCommands("./commands") path, which is not needed but for People that don't afford to change all its commands.

//Lets say, you used `bot.loadCommands("./commands")
//but you want to change the path
// to `./myOtherCommands`
// with eval (Example $djsEval)

client.CommandHandler.changeDBDLoadCommandsPath("./myOtherCommands")
  • resolvePath(absolutePath/Path) - Returns a Full version of given Path

Example

//As example if we run the file in `/home/runner/myBotProject`
dbdUtil.resolvePath("./myCommands") // will Return `/home/runner/myBotProject/myCommands`

Something went wrong? Errors? Bugs? Suggestions?

You can join the dbd.js Support Server or Direct Message me in Discord, ID 502968724207304714.

License

See MIT License for License