Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
dcjs-botfuncs
Advanced tools
Readme
Discord: not funny#8951
Please report bugs to me via discord!
Since discord likes to torture us with the new discord.js v14, I decided to create this package.
This package is all about making bot-writing easier.
It mainly focuses on creating server-settings, formatting messages and bot-config.
Obviously: npm install discord.js@14.1.2
You may import the functions by using
// 👇 only use when creating another Botfuncs instance
const BotfuncsType = require("dcjs-botfuncs");
const Botfuncs = new BotfuncsType();
Making a bot config and server storage:
In order to make implementation easier, your bot should have a config file.
It should at least have the prop "prefix", to set a bot default-prefix, the prop "author" to give credit, and the prop "description" for context.
Quick example of how to use dcjs-botfuncs:
bot-config.json:
A bot default-prefix is the only prop that is required,
but many people also include their token, client id, name, description, ... in their config.
Example:
{
"prefix": "!",
"name": "Best Bot!",
"author": "awesome people",
"description": "does awesome things",
"token": "your-token-here",
"id": "your-application-id-here"
}
index.js:
/* INDEX.JS */
// import/require ...
Botfuncs.setBotConfig(file); // 👈 file to your bot config
Botfuncs.initServers(file); // 👈 file to store your servers
Botfuncs.validateServers(); // 👈 validates and updates the server's data (not absolutely necessary)
client.once("ready", () => {
//ENTIRELY OPTIONAL: set Commands to use them in execCommand() later
Botfuncs.setGlobalCommandDir("./commandsDirectory"); // 👈 set the directory with all the
// commands inside (SEE: seperate command file example)
const rest = new REST({version: '10'}).token(BOT_TOKEN);
Botfuncs.putGlobalCommandsToAPI(client.user.id, rest); // 👈 PUT the global commands on the discord api
// and thereby making then slash-commands
console.log("Bot is now ready");
});
client.on("interactionCreate", async (interaction) => {
Botfuncs.onInteraction(interaction, (command, options, author, guildId) => {
if(command === "help") return Botfuncs.execInteractionCommand("healp", guildId, ...params/*👈 your params in the interact() function */)
})
})
client.on("messageCreate", async (message) => {
Botfuncs.onMessage(message, (command, args, author, guildId, usedPrefix) => {
Botfuncs.addServer(message.guildId); // 👈 will store, save and update the server the message was created on
// if(usedPrefix === Botfuncs.getServerProp(guildId, "prefix"))
// 👆 without filter, onMessage will react to commands using the SERVER-PREFIX AND CONFIG-PREFIX
if(command === "ping") {
//👇 "reply", message, deleteTimeout, asEmbed?, deleteReplyTimeout ... (delTimeout & delReplyTimeout: 0 = don't delete )
return Botfuncs.sendMessage("pong", message, 4000, false, 0);
} else if(command === "complexCommand") {
return Botfuncs.execCommand("complexCommand", guildId, ...params /*👈 your params in the execute() function */ );
}
// ...
});
});
// ...
Example of a seperate command file:
module.exports = {
name: "commandName", // 👈 used as identifier
description: "description",
args: [ // 👈 important for slash-commands
{ name: "arg1", description: "descrp1", required: true },
{ name: "arg2", description: "descrp2" },
],
private: false, // 👈 if this command should be hidden for the system
execute(/* EXAMPLE PARAMETERS! Fully Customizable! */ message, args, client, prefix) {
message.channel.send("I know it's complicated, but you'll get a hang of it!");
},
interact(/* EXAMPLE PARAMETERS! Fully Customizable! */ interaction, options) {
interaction.reply("I know it's complicated, but you'll get a hang of it!");
}
}
must use before discord-client is ready:
must use upon messageCreate:
should use in context of commands:
should use in context of interactions:
good-to-know functions:
FAQs
discord bot helper - let the api do the hard work for you
The npm package dcjs-botfuncs receives a total of 0 weekly downloads. As such, dcjs-botfuncs popularity was classified as not popular.
We found that dcjs-botfuncs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.