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

djs-utilities

v1.1.2

Published

Some handy utilities for discord.js bots

Downloads

16

Readme

Some handy utilities for discord.js bots

Homepage

Install

npm install djs-utilities

Docs

Initialization:

const Discord = require('discord.js');
const client = new Discord.Client();
const djsUtils = require('djs-utilities');
const utils = new djsUtils.Utils(client);

getUser

Get a Discord User securily using mention, name, or id.

| Parameters | Type | Optional | Description | Example | | --- | --- | --- | --- | --- | | mention | < User Mention, String > | No | Preferably pass an argument from your arguments array. | args[0] | | mentionOnly | < Boolean > | Yes | If true, this will only get the user from a mention and return nothing if it's not a mention. | true |

Returns: UserObject

getRoles

Get a Discord Roles securily using mention, name, or id.

| Parameters | Type | Optional | Description | Example | | --- | --- | --- | --- | --- | | mention | < Role Mention, String > | No | Preferably pass an argument from your arguments array. | args[1] | | roles | < RoleManager > | No | Must pass guild.roles | guild.roles |

Returns: RoleObject

getChannels

Get a Discord Channel securily using mention, name, or id.

| Parameters | Type | Optional | Description | Example | | --- | --- | --- | --- | --- | | mention | < Channel Mention, String > | No | Preferably pass an argument from your arguments array. | args[0] | | channels | < GuildChannelManager> | No | Must pass guild.channels | guild.channels |

Returns: ChannelObject

getTime

Get a sufficient time, from ms, in a format that wont trigger OCD.

| Parameters | Type | Optional | Description | Example | | --- | --- | --- | --- | --- | | s | < Number > | No | Must be a number, as it will calculate the time from the millisecond input in this parameter. Advice: Use endtime-Date.now() | res.endTime-Date.now() |

Returns: String

getStringTime

Get a sufficient string time, from ms, in a format that wont trigger OCD.

| Parameters | Type | Optional | Description | Example | | --- | --- | --- | --- | --- | | s | < Number > | No | Must be a number, as it will calculate the time from the millisecond input in this parameter. Advice: Use endtime-Date.now() | res.endTime-Date.now() | | dontUseMs | < Boolean > | Yes | Whether or not to calculate using seconds. | true |

Returns: String

setTime

Set a sufficient endtime with the choices s, m, h, d, w, which you can work our what does.

| Parameters | Type | Optonal | Description | Example | | --- | --- | --- | --- | --- | | time | < String > | No | Must be a string as it uses both numbers and variables in the same parameter. | args[1] |

Returns: Number (milliseconds)

getPages

Easily get pages for your large lists.

| Parameters | Type | Optional | Description | Example | | --- | --- | --- | --- | --- | | fullArr | < Array > | No | The array of which to make the pages from. | ['apple', 'pineapple', 'orange', 'grape', 'melon', 'avocado'] | | pageNum | < Number > | No | The page requested. | 1 | | amountPerPage | < Number > | Yes | The amount of items per page. Please keep this consistent for the people with OCD. default: 5 | 10 |

Returns: Object: {pages: pages, amount: `${pageNum}/${pagesAmount}`}

setCleanTitle & setCleanFooter

Check if a message ends with -c or -clean, if it does, this will make it not make a title/footer, if it does not, it will create the title/footer.

| Parameters | Type | Optional | Description | Example | | --- | --- | --- | --- | --- | | message | < MessageObject > | No | The message object, of which it checks the content for. | message | | embed | < MessageEmbed > | No | The embed of which to make clean/not clean. | embed | | title/footer | < String > | No | The title/footer to put in the embed if it's not clean. | Banned! |

Returns: Promise: It sets the values in the embed.

sendSafeEmbed

In case the bot doesn't have permissions to send embeds, this function will try sending it. If it can't, it will send it as a normal message.

| Parameters | Type | Optional | Description | Example | | --- | --- | --- | --- | --- | | embed | < MessageEmbed > | No | The embed of which we're trying to send. | embed | | channel | < ChannelObject > | No | The channel of where we will send the embed/message. | channel |

Returns: Promise: It sends the embed and sends it as a message if no perms for embeds.

unHoist

Unhoist a string.

| Parameters | Type | Optional | Description | Example | | --- | --- | --- | --- | --- | | name | < String > | No |The string to unhoist. Usually, this would be a member's display name. | member.displayName or ! Hoister |

Returns: String

Author

Kitsuyo

Contributing

Contributions, issues and feature requests are welcome!Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

License

Copyright © 2020-2021 Kitsuyo. This project is MIT licensed.