1.1.2 • Published 3 years ago

djs-utilities v1.1.2

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

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.

ParametersTypeOptionalDescriptionExample
mention< User Mention, String >NoPreferably pass an argument from your arguments array.args[0]
mentionOnly< Boolean >YesIf 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.

ParametersTypeOptionalDescriptionExample
mention< Role Mention, String >NoPreferably pass an argument from your arguments array.args[1]
roles< RoleManager >NoMust pass guild.rolesguild.roles

Returns: RoleObject

getChannels

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

ParametersTypeOptionalDescriptionExample
mention< Channel Mention, String >NoPreferably pass an argument from your arguments array.args[0]
channels< GuildChannelManager>NoMust pass guild.channelsguild.channels

Returns: ChannelObject

getTime

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

ParametersTypeOptionalDescriptionExample
s< Number >NoMust 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.

ParametersTypeOptionalDescriptionExample
s< Number >NoMust 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 >YesWhether 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.

ParametersTypeOptonalDescriptionExample
time< String >NoMust 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.

ParametersTypeOptionalDescriptionExample
fullArr< Array >NoThe array of which to make the pages from.['apple', 'pineapple', 'orange', 'grape', 'melon', 'avocado']
pageNum< Number >NoThe page requested.1
amountPerPage< Number >YesThe amount of items per page. Please keep this consistent for the people with OCD. default: 510

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.

ParametersTypeOptionalDescriptionExample
message< MessageObject >NoThe message object, of which it checks the content for.message
embed< MessageEmbed >NoThe embed of which to make clean/not clean.embed
title/footer< String >NoThe 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.

ParametersTypeOptionalDescriptionExample
embed< MessageEmbed >NoThe embed of which we're trying to send.embed
channel< ChannelObject >NoThe 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.

ParametersTypeOptionalDescriptionExample
name< String >NoThe 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.