
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
djs-builder
Advanced tools
Welcome to the Discord Bot Utilities package! 🥏 This package provides a set of utility classes/interfaces to simplify 🎍 common tasks when developing Discord bots using the Discord.js library ✨.
Starter provides functionality for initializing and starting a Discord bot 🤖.
Features:
⚠️ NOTE:
Any option you don't want, justDELETE 🗑️
the optionLINE ➖
!
const { Starter } = require('djs-builder'); // cjs module .js
const { Client, GatewayIntentBits, Partials } = require('discord.js');
const client = new Client({
intents: Object.keys(GatewayIntentBits).map((a) => {
return GatewayIntentBits[a];
}),
});
// Define starter options
const starterOptions = {
bot: {
token: 'YOUR_BOT_TOKEN', // [OPTIONAL] Discord bot token
logs: {
terminal: true // [OPTIONAL] Log messages to terminal
},
Status: {
state: 'online', // Required: Bot presence state ['online', 'offline', 'dnd', 'idle', 'Streaming']
activities: ['Game 1', 'Game 2'], // [OPTIONAL] Bot activities
type: 0, // [OPTIONAL] Bot activity type
delay: 60000 // [OPTIONAL] Activity rotation delay in milliseconds
},
Database: {
mongo: {
mongoURI: 'mongodb://localhost:27017', // Required: MongoDB connection URI
dbName: 'your_database_name' // [OPTIONAL] MongoDB database name
},
verse: {
adapterType: 'json', // Required: Database adapter type ['json', 'yaml', 'sql']
path: '/database/folder', // Required: Path to database folder [Note: "Not path to file!"]
dev: {
enable: true, // Required: Enable development mode
logsPath: '/path/to/logs' // [OPTIONAL] Path to development logs [Note: "It will create logs file for database executions logs!"]
},
secure: { enable: false, secret:'your_encryption_key'} // [OPTIONAL] To secure Data File by encrypting it with secret key
}
}
},
slash: {
path: './path/to/slash_commands', // Required: Path to slash commands
global: true, // [OPTIONAL] Register slash commands globally
serverId: '123456789012345678', // [OPTIONAL] Discord server ID
logsId: '123456789012345678' // [OPTIONAL] Logs channel ID
},
prefix: {
path: './path/to/prefixes', // Required: Path to prefix settings
prefix: '!', // Required: Default bot prefix
global: true, // [OPTIONAL] Use global prefix
serverIds: ['123456789012345678'], // [OPTIONAL] Discord server IDs
logsId: '123456789012345678' // [OPTIONAL] Logs channel ID
},
events: {
path: './path/to/events', // Required: Path to event handlers
recursive: true, // [OPTIONAL] Enable recursive event loading
eventBlacklist: ['path/to the event/file.js', 'path/to the event/file.js'] // [OPTIONAL] Blacklisted events
},
anticrash: {
enable: true, // Required: Enable anti-crash feature
webhookURL: 'https://your.crash.webhook.url', // Required: Webhook URL for crash alerts
mention: '<@123456789012345678>' // [OPTIONAL] User ID to mention in crash alerts
}
};
const bot = new Starter();
bot.start(client, starterOptions);
const { Starter } = require('djs-builder'); // cjs module .js
const { Client, GatewayIntentBits, Partials } = require('discord.js');
const client = new Client({
intents: Object.keys(GatewayIntentBits).map((a) => {
return GatewayIntentBits[a];
}),
});
// OR
import { Starter } from 'djs-builder'; // Ejs module .mjs or Ts
import { Client, GatewayIntentBits, Partials, PermissionFlagsBits } from 'discord.js';
const intentsArray = Object.keys(GatewayIntentBits)
.map((a) => GatewayIntentBits[a as keyof typeof GatewayIntentBits]);
const intents = intentsArray.reduce((acc, curr) => acc | curr, 0);
const client = new Client({
intents,
partials: Object.values(Partials) as Partials[],
});
// Define starter options
const starterOptions = {
bot: {
token: 'YOUR_BOT_TOKEN', // [OPTIONAL] Discord bot token
logs: {
devLogs: {
enable: true, // Required: Enable developer logs
pathToWatch: '/path/to/watch', // Required: Path to watch for file changes
webhookURL: 'https://your.webhook.url', // Required: Webhook URL for logging
mention: '<@123456789012345678>' // [OPTIONAL] User ID to mention in logs
},
terminal: true // [OPTIONAL] Log messages to terminal
},
name: 'Your Bot Name', // [OPTIONAL] Bot name
avatar: 'https://your.bot/avatar.png', // [OPTIONAL] Bot avatar URL or local path image
banner: 'https://your.bot/banner.png', // [OPTIONAL] Bot banner URL or local path image
BotInfo: {
perms: ['SendMessages', 'BotMessages'], // [OPTIONAL] Bot permissions to work in any server
serverId: '123456789012345678', // [OPTIONAL] Discord server ID
botInvite: 'https://discord.com/invite/your-bot-invite', // [OPTIONAL] Bot invite URL
serverInvite: 'https://discord.com/invite/your-server-invite', // [OPTIONAL] Server invite URL
ownerId: '123456789012345678', // [OPTIONAL] Bot owner's user ID
partners: ['partner1', 'partner2'] // [OPTIONAL] Bot partners
},
Status: {
state: 'online', // Required: Bot presence state ['online', 'offline', 'dnd', 'idle', 'Streaming']
activities: ['Game 1', 'Game 2'], // [OPTIONAL] Bot activities
type: 0, // [OPTIONAL] Bot activity type
delay: 60000 // [OPTIONAL] Activity rotation delay in milliseconds
},
Database: {
mongo: {
mongoURI: 'mongodb://localhost:27017', // Required: MongoDB connection URI
dbName: 'your_database_name' // [OPTIONAL] MongoDB database name
},
verse: {
adapterType: 'json', // Required: Database adapter type ['json', 'yaml', 'sql']
path: '/database/folder', // Required: Path to database folder [Note: "Not path to file!"]
dev: {
enable: true, // Required: Enable development mode
logsPath: '/path/to/logs' // [OPTIONAL] Path to development logs [Note: "It will create logs file for database executions logs!"]
},
secure: { enable: false, secret:'your_encryption_key'} // [OPTIONAL] To secure Data File by encrypting it with secret key
}
}
},
slash: {
path: './path/to/slash_commands', // Required: Path to slash commands
global: true, // [OPTIONAL] Register slash commands globally
serverId: '123456789012345678', // [OPTIONAL] Discord server ID
logsId: '123456789012345678' // [OPTIONAL] Logs channel ID
},
prefix: {
path: './path/to/prefixes', // Required: Path to prefix settings
prefix: '!', // Required: Default bot prefix
global: true, // [OPTIONAL] Use global prefix
serverIds: ['123456789012345678'], // [OPTIONAL] Discord server IDs
logsId: '123456789012345678' // [OPTIONAL] Logs channel ID
},
events: {
path: './path/to/events', // Required: Path to event handlers
recursive: true, // [OPTIONAL] Enable recursive event loading
eventBlacklist: ['path/to the event/file.js', 'path/to the event/file.js'] // [OPTIONAL] Blacklisted events
},
anticrash: {
enable: true, // Required: Enable anti-crash feature
webhookURL: 'https://your.crash.webhook.url', // Required: Webhook URL for crash alerts
mention: '<@123456789012345678>' // [OPTIONAL] User ID to mention in crash alerts
}
};
// Define the starter instance
const bot = new Starter();
async function botStart() {
const botstarted = await bot.start(client, starterOptions);
const mongodb = await botstarted.mongodb;
const versedb = await botstarted.versedb;
const slashSize = await botstarted.slashSize;
const prefixSize = await botstarted.prefixSize;
const eventSize = await botstarted.eventSize;
return {
getDb: mongodb,
db: versedb,
slashSize: slashSize,
prefixSize: prefixSize,
eventSize: eventSize
}
}
module.exports = { botStart };
// Or
export { botStart };
const { botStart } = require('path/to/file/where botStart is exported from');
// Or
import { botStart } from 'path/to/file/where botStart is exported from';
async function test() {
const client = await botStart();
// Usage for mongoDb
const db = await client.getDb;
await db.collection('collectionName'); // See more usage at https://www.mongodb.com
// Usage for verseDb
const db = await client.db;
await db.load('collectionName'); // See more usage at https://versedb.jedi-studio.com
// Usage for slashSize/prefixSize/eventSize
console.log(`loaded slash Commands: ${client.slashSize}`);
console.log(`loaded prefix Commands: ${client.prefixSize}`);
console.log(`loaded events: ${client.eventSize}`);
}
test()
Build 🔵Button , 🧾Menu or 🏅PermissionChecker
Than the discord.js
🔵 ButtonManager is a utility class for managing the creation of Discord buttons ✨.
const { ButtonManager } = require('djs-builder'); // Cjs module .js
// OR
import { ButtonManager } from 'djs-builder'; // Ejs module .mjs or Ts
// Define button data
const buttonsData = [
{
customId: 'button1',
style: 'Primary',// style: Primary, Secondary, Link, Danger, Success
label: 'Primary Button',
emoji: '😃', // Emoji for the button
disabled: false, // Whether the button is disabled
},
{
customId: 'button2',
style: 'Secondary',
label: 'Secondary Button',
emoji: '🚀',
disabled: true,
},
{
style: 'Link',
label: 'Link Button',
url: 'https://example.com', // URL for link-style button
emoji: '🔗',
},
];
// Create an instance of ButtonManager
const actionRow = new ButtonManager(buttonsData);
// Buttons Row add it into components
const row = actionRow.ButtonBuild();
// Exmaple
const message = await interaction.channel.send({ content: 'Here are some buttons:', components: [row] });
// OR
const message = await message.channel.send({ content: 'Here are some buttons:', components: [row] });
🧾 MenuManager facilitates the creation of select menus (dropdown menus) in Discord ✨.
const { MenuManager } = require('djs-builder'); // Cjs module .js
// OR
import { MenuManager } from 'djs-builder'; // Ejs module .mjs or ts
// Define select menu options
const selectMenuOptions = [
{ label: 'Option 1', value: 'option1', description: 'Description for Option 1', emoji: '🌟', default: true },
{ label: 'Option 2', value: 'option2', description: 'Description for Option 2', emoji: '🚀' },
{ label: 'Option 3', value: 'option3', description: 'Description for Option 3', emoji: '🔗' },
];
// Create an instance of SelectMenuManager
const selectMenuManager = new MenuManager(
selectMenuOptions,
'customSelectMenuId', // Custom ID for the select menu
'Select an option', // Placeholder text for the select menu
1, // Minimum number of selected values
2, // Maximum number of selected values
false // Disabled state for meny (true or false)
);
// Create a select menu with the specified options
const selectMenuRow = selectMenuManager.createSelectMenu();
// Define a message with the select menu
message.reply({
content: 'Please choose an option:',
components: [selectMenuRow],
});
// Define a interaction with the select menu
interaction.reply({
content: 'Please choose an option:',
components: [selectMenuRow],
});
PermissionChecker provides functionality for checking user permissions in a Discord guild ✨.
const { PermissionChecker } = require('djs-builder'); // Cjs module .js
// OR
import { PermissionChecker } from 'djs-builder'; // Ejs module .mjs or ts
const perms = new PermissionChecker();
// Interaction case
const userId = interaction.user.id;
const guild = interaction.guild;
// Message Case
const guild = message.guild;
const memberId = message.author.id;
// Usage:
const permToCheck = ['ManageGuild', 'BanMembers']
perms.checker(userId, guild, permToCheck)
Contributions are welcome! If you have any suggestions, bug reports, or feature requests, feel free to contact us on discord.
FAQs
Discord.js bot builder. Supports Ts and Js.
We found that djs-builder demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.