This is a module made specifically for my(AqilCont)'s and his friends' use.
npm i rfasqls
This feature was made to make making bots easier. Has some helpful functions too. Usage:
const { discord } = require("rfasqls"),
bot = new discord(client, { (Options) });
The object it returns also has its own custom event emitter. Some useful events:
no-command
: When a message is sent and it is not a command recognized by the package.dm
: When the bot is "DM"ed.
name(String)
(required): Name of this botprefix(String)
(required): The prefixadmins(Array<String>)
: IDs of all the administrators of the bot. Info is mainly used for theeval
feature.cats(Array<String>)
: Names of all the categories going to be includedcooldowns(Object)
: Enables cooldowns(makes a user wait for a set amount of time before using a command again) and global cooldowns. Leave empty if you want them both to work. To set one or both of them off, input this into it:{ cd: false, gcd: false }
A custom eval
command for anyone to use.
evalopt(Object)
: You can set the prefix and function through this. This is recommended opposed toevalprefix
and/orevalfunc
. Properties:prefix(String)
andfunc(Function)
evalprefix(String)
: Sets the custom prefix of the eval command. Eg. If the value is set tor:
, the usage isr: (code)
evalfunc(Function)
: Sets the function of theeval
command
Messages for certain event triggers like startup, cooldowns, and global cooldowns. Default messages are used if not set to anything.
messages(Object)
: Messages for cooldowns... in an object. Properties:cd
: Cooldownsgcd
: Global cooldownsready
: Bot Startup
cdMessage
:
Some helpful functions that shorten your code. To access the functions, you need to do this:
const { functions } = require("rfasqls");
random(min(Number), max(Number), round(Boolean))
: Spawns a random number frommin
tomax
. Rounds the number if you puttrue
for theround
argument.page_maker(array(Array), num(Number), page(Number), func(Function))
: You put in an array, then it executes the function including thenum
amount of values per "page". Specify the page number if you are not on page 1time(time(Number or String), type(string))
: Converts milliseconds into a string, and the ISO format into units of time. Has other secret functionalities too.bytes(bytes(Number))
: Converts a number into a unit of Bytes, MegaBytes, GigaBytes, or TerraBytesget_val(obj(Object), str(String))
: IDK how to explain this but its a cool function that can get values from objects with random strings. Returns false if value not found.parseUrl(url(String))
: Returns a promise that resolves with JSON from a given URL.capFirst(str(String))
: Capitalizes the first letter of each word in a string.check(arr(Object or Array), type(Array or String))
: This one is KINDA hard to explain and use. I would recommend ignoring it.equals(a(Anything), b(Anything), check_order(Boolean), crylic(Boolean))
: Returns true or false depending ifa
is equal tob
. Most handy when working with objects, or other complex values.
This feature works a lot like the events
module but is a lot simpler and has global events(events across the whole project). To access this feature, do this:
const { events } = require("rfasqls");
In essence, the whole events
object is an event emitter. You can call it anywhere and the same events will be called through your project(Example: socket.io
except you need to do stuff to make it works with HTML).
To create a local Event Emitter, just do:
const { events } = require("rfasqls"),
e = new events();
This will create and return an object that only works in this file.
BTW I didn't just spam type
rfasqls
... it is an abbreviation for something I probably should have written down somewhere ;-;