-
First we create a node.js file (If you have not downloaded node.js to computer before, you can download node.js by clicking here)
-
Then we open the PowerShell terminal by "shift + right click" on the folder of the file you created.
-
Then we write npm i dcjs-util and press enter.
-
Download the dcjs-util module
-
And now we have downloaded the dcjs-util module, congratulations 🎉🎉
-
This module allows you to easily use commands using the discord.js library
-
It increases the performance of your bot by making discord.js more performant than commands in some commands
-
Moreover, we add comment lines so that you can understand the commands so that you can edit the commands
-
This module was made with the sole purpose of helping people, without generating any income
It's very simple, first you have to open your discord bot file and write the following in it:
const DiscordUtils = require("dcjs-util");
const memberRoleId = "12345678901234567";
client.on("messageCreate", async (message) => {
// If user is bot
if (message.author.bot) return;
if (message.content.toLowerCase() == "!role") {
const member = message.member;
// If user doesn't have member role
if (!DiscordUtils.hasRole(member, memberRoleId)) {
try {
// Add role
await DiscordUtils.addRole(member, memberRoleId);
return message.reply({
content: `Successfully added role <@&${memberRoleId}>!`,
allowedMentions: {
repliedUser: true,
roles: [],
},
});
} catch (error) {
// If an error occurred
console.log(error);
message.reply("Something went wrong!");
}
}
// If user has member role
else {
try {
// Remove role
await DiscordUtils.removeRole(member, memberRoleId);
return message.reply({
content: `Successfully removed role <@&${memberRoleId}>!`,
allowedMentions: {
repliedUser: true,
roles: [],
},
});
} catch (error) {
// If an error occurred
console.log(error);
message.reply("Something went wrong!");
}
}
}
});
const DiscordUtils = require("dcjs-util");
client.on("messageCreate", async (message) => {
// If user is bot
if (message.author.bot) return;
if (message.content.toLowerCase().startsWith("!countrole")) {
// Capture the roles she/he tagged or entered the ID in the message
const allRoles = DiscordUtils.fetchRolesInContent(
message.guild,
message.content
);
return message.reply(
`You mentioned exactly ${DiscordUtils.toHumanize(
allRoles.size
)} roles in your message`
);
} else if (message.content.toLowerCase().startsWith("!countchannel")) {
// Capture the channels she/he tagged or entered the ID in the message
const allChannels = DiscordUtils.fetchChannelsInContent(
message.guild,
message.content
);
return message.reply(
`You mentioned exactly ${DiscordUtils.toHumanize(
allChannels.size
)} channels in your message`
);
} else if (message.content.toLowerCase().startsWith("!countmember")) {
// Capture the members she/he tagged or entered the ID in the message
const allMembers = DiscordUtils.fetchMembersInContent(
message.guild,
message.content
);
return message.reply(
`You mentioned exactly ${DiscordUtils.toHumanize(
allMembers.size
)} members in your message`
);
} else if (message.content.toLowerCase().startsWith("!countuser")) {
// Capture the users she/he tagged or entered the ID in the message
const allUsers = DiscordUtils.fetchUsersInContent(
message.guild,
message.content
);
return message.reply(
`You mentioned exactly ${DiscordUtils.toHumanize(
allUsers.size
)} users in your message`
);
}
});
const DiscordUtils = require("dcjs-util");
client.on("messageCreate", async (message) => {
if (message.author.bot) return;
if (message.content.toLowerCase() == "!serverinfo") {
const guildInfos = await DiscordUtils.guildInfo(message.guild);
const embed = new Discord.EmbedBuilder()
.setAuthor({
name: guildInfos.name,
iconURL: guildInfos.iconURL ?? null,
})
.setDescription(
`**• Created Date:** <t:${Math.floor(
guildInfos.createdTimestamp / 1000
)}:R>`
)
.addFields(
{
name: "GUILD INFORMATION",
value:
`🆔 **ID:** ${guildInfos.id}\n` +
`👥 **Member Count:** ${DiscordUtils.toHumanize(
guildInfos.memberCount
)}\n` +
`🎨 **Icon:** ${
guildInfos.iconURL
? `[Icon Link](${guildInfos.iconURL})`
: `~~[Icon Link]~~`
}\n` +
`🖼️ **Banner:** ${
guildInfos.bannerURL
? `[Banner Link](${guildInfos.bannerURL})`
: `~~[Banner Link]~~`
}`,
inline: true,
},
{
name: "OTHER INFORMATION",
value:
`📅 **Created Date:** <t:${Math.floor(
guildInfos.createdTimestamp / 1000
)}:D>\n` +
`🌍 **Region:** ${guildInfos.preferredLocale}\n` +
`🚀 **Verification Level:** ${guildInfos.verificationLevel}`,
inline: true,
},
{
name: "CHANNELS & ROLES",
value:
`📚 **Channels:** ${guildInfos.channels.size}\n` +
`✏️ **Text Channel:** ${guildInfos.textChannels.size}``🔒 **Roles:** ${guildInfos.roles.size}`,
inline: true,
},
{
name: "FEATURES",
value: `${guildInfos.features
.map((feature) => `• ${feature}`)
.join("\n")}`,
inline: false,
}
)
.setThumbnail(guildInfos.iconURL ?? null)
.setColor("Random")
.setTimestamp();
return message.reply({
embeds: [embed],
});
}
});
const DiscordUtils = require("dcjs-util");
client.on("messageCreate", async (message) => {
// If user is bot
if (message.author.bot) return;
if (message.content.toLowerCase() == "!botinfo") {
const botInfos = await DiscordUtils.botInfo(message.client.user);
// Read memory
function readMemory(usedMemory) {
function baytToMegabayt(number, fixed = 0) {
return (number / 1024 / 1024).toFixed(fixed);
}
function baytToGigabayt(number, fixed = 1) {
return (number / 1024 / 1024 / 1024).toFixed(fixed);
}
const gigabayt = baytToGigabayt(usedMemory);
// If the used memory is greater than or equal to 1 GB, return the used memory in GB
return gigabayt >= 1
? `${gigabayt} GB`
: `${baytToMegabayt(usedMemory)} MB`;
}
// Create an embed
const embed = new Discord.EmbedBuilder()
.setAuthor({
name: botInfos.globalName,
iconURL: botInfos.displayAvatar,
})
.setDescription(
`**• Last reboot:** <t:${Math.floor(botInfos.readyTimestamp / 1000)}:R>`
)
.addFields(
{
name: "BOT INFORMATION",
value:
`✏️ **My username:** ${botInfos.name}\n` +
`🆔 **Discord ID:** ${botInfos.id}\n` +
`📅 **My founding date:** <t:${Math.floor(
botInfos.createdTimestamp / 1000
)}:F>\n` +
`🎚️ **RAM usage:** ${readMemory(botInfos.usedMemory)} - %${
botInfos.usedMemoryPercentage
}`,
inline: true,
},
{
name: "MY DELAY INFORMATION",
value: `📡 **Bot's main delay:** ${botInfos.ping} ms`,
inline: true,
},
{
name: "SERVER INFORMATION",
value:
`💻 **Number of servers:** ${DiscordUtils.toHumanize(
botInfos.guildCount
)}\n` +
`👥 **Number of users:** ${DiscordUtils.toHumanize(
botInfos.userCount
)}\n` +
`🎞️ **Number of channels:** ${DiscordUtils.toHumanize(
botInfos.channelCount
)}\n` +
`🏷️ **Number of roles:** ${DiscordUtils.toHumanize(
botInfos.roleCount
)}\n` +
`🎉 **Number of emojis:** ${DiscordUtils.toHumanize(
botInfos.emojiCount
)}`,
inline: true,
},
{
name: "VERSIONS",
value:
`🎛️ **Node.js version:** ${process.version}\n` +
`🔨 **Discord.js version:** v${Discord.version}`,
inline: true,
},
{
name: "VDS INFORMATION",
value:
`🎞️ **CPU:** ${botInfos.cpuName}\n` +
`🔋 **Total ram:** ${readMemory(
botInfos.totalMemory
)} (**Free:** ${readMemory(botInfos.freeMemory)})`,
}
)
.setThumbnail(botInfos.displayAvatar)
.setColor("Random")
.setTimestamp();
// Send the embed
return message.reply({
embeds: [embed],
});
}
});
By typing this you can access all commands of the module!
-
The first reason is that it is overly simple and less likely to fail
-
The second reason is that since it is an open source module, it can be edited in a special way if you want
-
The third reason is that we are improving this module every day, making it more performance and adding new features to our strength
-
The fourth reason is... Well, I guess there's no other reason :( Maybe it's just to make me happy 👉👈
Please do not forget to use it in the latest version for more stable and performance of the module!
-
If you want to support this module, if you request me on github, I will be happy to help you.
-
Thank you for reading this far, i love you 💗
-
See you in my next modules!