Package Exports
- djs-helper
- djs-helper/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (djs-helper) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
djs-helper
djs-helper is a JavaScript library that helps you to develop your own Discord Bot, Still under development, more features will be added in the future
Installation
- Download Node.js
- Write in CMD / Terminal:
npm i djs-helperExample Code:
const { Client, Intents, MessageEmbed } = require('discord.js');
const DjsH = require('djs-helper');
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('messageCreate', async (message) => {
if (!message.guild) return;
if (message.startsWith('!extract-emojis')) {
let emojis = DjsH.matchEmojis(message.content, true);
if (emojis.length === 0) {
let embed = new MessageEmbed()
.setTitle("Extract Emojis")
.setDescription("❌ No emoji found!")
.setColor(DjsH.Colors.HEX.Red)
return message.reply({ embeds: [embed] });
} else {
let embed = new MessageEmbed()
.setTitle("Extract Emojis")
.setDescription(`Emojis found: \`${emojis.join(',')}\``)
.setColor(DjsH.Colors.HEX.Aqua)
message.reply({ embeds: [embed] });
}
}
});
client.login('token');Documentation
Functions:
| Name | Params | Type | Function | Returns |
|---|---|---|---|---|
| matchId() | content |
String |
Extract All Discord IDs from content |
Array |
| matchEmojis() | content,unicode |
String,Boolean |
Extract All Discord Emojis from content, If unicode is true it will return Unicode emojis too |
Array |
| isInvite() | content |
String |
Checks if content contains Discord Invites |
Boolean |
| isURL() | content,whitelist |
String,Array |
Checks if content contains URLs |
Boolean |
| splitMessage() | content,max |
String,Number |
Split string every max default: 2000 max |
Array |
| await getMember() | guild,userID |
Object,String |
Get member from guild using ID |
Object/null |
| await guildsCount() | client |
Object (Discord.Client()) |
Get client guilds count (Supports Sharding) |
Number |
| await usersCount() | client |
Object (Discord.Client()) |
Get client users count (Supports Sharding) |
Number |
| await channelsCount() | client |
Object (Discord.Client()) |
Get client channels count (Supports Sharding) |
Number |
| await getUser() | client,userID |
Object (Discord.Client()),String |
Get user using ID |
Object/null |
| await Inviter() | client,member |
Object (Discord.Client()),Object (GuildMember) |
Get used invite |
Object |
Utils:
| Name | Function | Usage |
|---|---|---|
| Colors | Contains all colors | to Show all colors: console.log(Colors.HEX) |
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.