djs-utilities
v1.1.2
Published
Some handy utilities for discord.js bots
Downloads
5
Maintainers
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.