discord-utilities

1.0.0 • Public • Published

discord-utilities

A lightweight, updated and easy to use package with utility functions that you may need when developing a discord bot or javascript programs.

Bugs, Glitches & Issues

Open an issue in our github repository.

Help & Support

If you need help, join our discord server to talk and help with your code.

Installation

You can easily get it from NPM.

npm install discord-utilities

Functions

Reffering to Utils as const Utils = require("discord-utilities");.

Function Name Call Description Output
shuffleArray Utils.shuffleArray(array) Shuffles elements of a given array. Array
randomItem Utils.randomItem(array) Selects a random item of a given array. ArrayItem
isArray Utils.isArray(parameter) Returns if the given parameter is an array. Boolean
randomHex Utils.randomHex() Returns a vaid and random hexadecimal color code. String
randomNumber Utils.randomNumber(minimum, maximum) Returns a random number from inside minimum and maximum range. (Interval [minimum, maximum]) Integer
randomString Utils.randomString(length) Returns a random combination of letters and numbers of a specified length. String
roundFloat Utils.roundFloat(float, decimals) Default amount of decimals is 1. It keeps/adds decimals until the desired amont of decimals is hit. Float
includesNumber Utils.includesNumber(string) Returns true if the string contains any numbers inside it. Boolean
isNumber Utils.isNumber(parameter) Returns true if the given parameter is a finited number. Boolean
fetchTime Utils.fetchTime(ms, object) It fetches the amount of ms to human readable time, If object function is set to true, it will output an object with the values, otherwise it will output a formated string, false by default. String or Object
toProperCase Utils.toProperCase(string) It sets the first letter of every word inside the string to upper case. String
isObject Utils.isObject(parameter) It returns true if given parameter is a JSON object. Boolean
wait Utils.wait(ms) Creates a promise that gets resolved after amount of miliseconds given. Can be used to pause script execution in an async scope by invoking the function with await keyword. Promise - Undefined
awaitReply Utils.awaitReply(message, id, question, limit) Creates a message collector in the channel where message was sent that waits for the first message sent by discord user whos id is equal to id, before starting colector the question is sent in the message's channel. If times out, it returns false otherwise it returns the message collected. Promise - False or Discord Message

Package Sidebar

Install

npm i discord-utilities

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

10.6 kB

Total Files

5

Last publish

Collaborators

  • mraugu