1.0.9 • Published 5 months ago
blackcat-djs v1.0.9
Installation
npm install blackcat-djs
Examples
You can read this example bot on GitHub: BlackCat-Bot
Launch of the module
import { Client as BlackCatClient } from "blackcat-djs";
import colors from "chalk";
const client = new BlackCatClient({
/*
discordClient: {
// Discord.Client
},
*/
config: {
tokenBot: "Token Bot",
prefix: "!",
developer: "owner id",
// you can add whatever you want.
// ouput: client.config.etc
},
// Run events suggested by blackcat
commandHandler: {
prefixCommand: true, // enable or disable running command with prefix
slashCommand: true, // enable or disable running slash commands
setLanguage: "en", // package's custom language. Currently only supports 2 languages: vi: Vietnamese and en: English
path: {
prefixCommand: "./Commands", // path to prefix commands
slashCommand: "./slashCommands", // path to slash commands
},
},
});
client.on("ready", async (bot) => {
console.log(colors.blue(bot.user.username + " is ready to operate"));
});
Prefix Commands
import { commandBuilders } from "blackcat-djs";
import { fileURLToPath } from 'node:url';
import path from "node:path";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const commands = new commandBuilders({
name: path.parse(__filename).name, // Main command name
usage: path.parse(__filename).name, // Usage when using the help command
category: path.parse(__dirname).name, // Command category
aliases: [], // Aliases for the command
description: "", // Description for the command
cooldown: 5, // Command cooldown time
owner: false, // Developer mode toggle
permissions: [] // Permissions required when using the command
}).addCommand(async (client, message, args, prefix) => {
// code
});
// console.log(commands.toJSON()); // Display command information in JSON format
export default commands;
NOTE
- The 'path' and 'url' modules will help you retrieve the command name and category more quickly, eliminating the need for manual handling. You can confidently utilize them without performing these tasks manually.
- You can check out the following instructions
slash Commands
import { ApplicationCommandOptionType, ApplicationCommandType } from "discord.js";
import { slashCommandBuilder } from "blackcat-djs";
import { fileURLToPath } from 'node:url';
import path from "node:path";
// Request structure
const slashCommand = new slashCommandBuilder({
name: path.parse(fileURLToPath(import.meta.url)).name, // Command name, can be in uppercase or lowercase as desired
description: "", // Command description
userPerms: [], // Permissions required for members to use the command
owner: false, // Set to true to make it a bot owner command, false to disable
cooldown: 3, // Command cooldown time
type: "",
// options: []
}).addSlashCommand((client, interaction) => {
// code
});
// console.log(slashCommand.toJSON());
export default slashCommand;
NOTE
- The 'path' and 'url' modules will help you retrieve the command name more quickly, eliminating the need for manual handling. You can confidently utilize them without performing these tasks manually.
- You can check out the following instructions
Convert hex color code to RGB format.
// client.blackcatclient
const hexColor = "#3498db";
const rgbArray = client.toRgb(hexColor);
console.log(rgbArray); // Output: [52, 152, 219]
Converts a time string into the corresponding value in milliseconds.
// client.blackcatclient
const timeString = "1w 3d 5h";
const totalTimeInMs = client.ms(timeString);
console.log(totalTimeInMs); // Output: 910800000 (total time in milliseconds)