Some handy utilities for discord.js bots
npm install djs-utilities
const Discord = require('discord.js');
const client = new Discord.Client();
const djsUtils = require('djs-utilities');
const utils = new djsUtils.Utils(client);
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
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
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
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
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
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)
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}`}
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.
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 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
Kitsuyo
- Website: https://kitsuyo.com/
- Twitter: @Aprixiaa
- Github: @Kitsuyo
Contributions, issues and feature requests are welcome!
Feel free to check issues page.
Give a ⭐️ if this project helped you!
Copyright © 2020-2021 Kitsuyo.
This project is MIT licensed.