README
❤ Powerful Discord Client with useful methods
Installation
$ npm install powerful-discord
Discord.js V13 allowed
Usage
import { Limiter, Client, util, Discord } from "powerful-discord"; // importing
// const { Limiter, Client, util, Discord } = require("powerful-discord");
const client = new Client({token: "BOT_TOKEN", colors: {main: "#00ffff"} }); // creating a discord client, token is required
const prefix = ">";
client.on("ready", () => { // basic ready event
console.log(`${client.user.tag} is online`)
})
t
const cmdLimiter = new Limiter(1, 5000); // creating a new limiter, 1 message per 5 seconds (1sec === 1000 ms)
// Examples
client.on("messageCreate", async (message) => { // message.content = ">example something here"
const args = message.content.slice(prefix.length).trim().split(/ +/g); // args = ["example", "something", "here"]
const cmd = args.shift().toLocaleLowerCase(); // cmd = "example" | args = ["something", "here"]
if (!message.content.toLocaleLowerCase().startsWith(prefix)) return;
const limitedUser = cmdLimiter.take(message.author.id); // checking an item, returns boolean, true if limited
if (limitedUser) return message.reply("cooldown");
if (cmd === "timestamp") {
const embed = client.embed("main").setAuthor({name: "hello"}).setDescription(client.timestamp());
message.reply({embeds: [embed]})
}
if (cmd === "wait") {
const anyTime = client.wait(Date.now() + 84561645);
message.reply(`You must wait more ${anyTime.hours} h. ${anyTime.minutes} m. ${anyTime.seconds} s.`);
}
if (cmd === "producerange") {
message.reply(client.produceRange({to: 10}).join(", ")) // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
message.reply(client.produceRange({from:5, to: 10}).join(", ")) // 5, 6, 7, 8, 9
}
if (cmd === "uuid") {
message.reply(client.uuid()) // a48qdb7q6d8u
// message.reply(client.uuid(undefined, 12)) // a48qdb7q6d8u
}
});
client.login(); // basic login method
Limiter class from main module
Limiter => DiscordJS Rate Limiter
import { Limiter } from "powerful-discord";
const limiter1 = new Limiter(4, 15000); // allows 4 uses every 15 seconds
// It can be used for commands cooldown
const limited = limiter1.take("some id");
if (limited) return; // returns true if limited
Additional Client Parameters
Client Class => Client
- Client.discord => Discord
- Client.colors => An object with given colors. They can be used with the embed method
- Client.util => dann-util, useful functions
Additional Methods
wait(date)
Useful for making cooldown.
PARAMETER | TYPE | OPTIONAL | DEFAULT |
---|---|---|---|
date | date | new Date() |
object => {
Returns:hours: number,
minutes: number,
seconds: number
}
randomItem(array)
Gives a random item from specified array.
PARAMETER | TYPE | OPTIONAL | DEFAULT |
---|---|---|---|
array | array | [] |
Returns: an element
produceRange(Options)
Give an array of numbers in specified range.
Options Object
PARAMETER | TYPE | OPTIONAL | DEFAULT |
---|---|---|---|
to | number | ||
from | number | 🗸 | 0 |
step | number | 🗸 | 1 |
#### Returns: array |
// Example
const fromFourToTen = client.produceRange({from: 4, to: 10}) // [4, 5, 6, 7, 8, 9]
timestamp(time, style)
Makes a discord timestamp.
PARAMETER | TYPE | OPTIONAL | DEFAULT |
---|---|---|---|
time | number | 🗸 | Date.now() |
style | TimestampStylesString | 🗸 | f |
#### Returns: string, Discord Timestamp |
uuid(type, length)
Generates a unique id.
PARAMETER | TYPE | OPTIONAL | DEFAULT |
---|---|---|---|
string | type | 🗸 | mixed |
length | number | 🗸 | 12 |
#### Returns: string | |||
```JavaScript | |||
// Example | |||
// Types: number, letters, mixed(not specified) |
client.uuid(); // 156asd1qwe1u client.uuid(null, 6); // as1d5q9r client.uuid("letters", 8); // aqjxqwnb client.uuid("numbers", 16); // 6958941798476178
### embed(color)
Changes the format of number ("1,000,000").
| PARAMETER | TYPE | OPTIONAL |DEFAULT
| ------------- |:-------------:|:---------:|:----:
| color | [ColorResolvable](https://discord.js.org/#/docs/discord.js/stable/typedef/ColorResolvable) or color from ColorObject | 🗸 |
#### Returns: [MessageEmbed](https://discord.js.org/#/docs/discord.js/stable/class/MessageEmbed)
```JavaScript
// Example
import { Client} from "powerful-discord"; // importing Client Class
const client = new Client({token: "BOT_TOKEN", colors: {main: "#00ffff", any: "#edff0f"} }); // creating a client
client.embed() // new MessageEmbed();
client.embed("any") // new MessageEmbed().setColor(client.colors.any); #edff0f
client.embed("#00ff00") // new MessageEmbed().setColor("#00ff00");
Join us!
- 💚 Util
- 💜 Discord Server