JSPM

cwk-ds-tools

1.0.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q20054F
  • License MIT

Zero-boilerplate Discord.js bot framework with built-in MongoDB, automod, slash commands, and more

Package Exports

  • cwk-ds-tools
  • cwk-ds-tools/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 (cwk-ds-tools) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

cwk-ds-tools 🚀

npm version License Discord

A zero-boilerplate Discord.js framework with built-in MongoDB, automod, slash commands, and more. Get your bot running in minutes!

Features ✨

  • Zero Boilerplate - Just create commands and go
  • Auto-modlog System - Track joins, leaves, deletions, and more
  • MongoDB Integration - Ready-to-use database connection
  • Automatic Slash Commands - Register commands with zero effort
  • Built-in Utility Commands - Help, ping, serverinfo, and more
  • Folder Auto-creation - No manual setup needed
  • TypeScript Support - Full type definitions included
  • Advanced Interaction Handling - Buttons, modals, and select menus

Installation 📦

npm install cwk-ds-tools
# or
yarn add cwk-ds-tools

Quick Start 🚀

  1. Create a .env file:
TOKEN=your_bot_token_here
MONGO_URI=mongodb://localhost:27017/your_db
OWNER_ID=123456789012345678
MODLOG_CHANNEL_ID=987654321098765432
  1. Create your first command (commands/general/ping.js):
module.exports = {
  name: 'ping',
  description: 'Check bot latency',
  slashCommand: true,
  
  async run(interaction, client) {
    const start = Date.now();
    await interaction.deferReply();
    const end = Date.now();
    
    await interaction.editReply({
      content: `🏓 Pong!\nBot: ${end - start}ms\nAPI: ${client.ws.ping}ms`
    });
  }
};
  1. Start your bot (index.js):
require('dotenv').config();
require('cwk-ds-tools')();

Advanced Usage 🛠️

Command Structure

module.exports = {
  name: 'command-name',
  description: 'Command description',
  slashCommand: true, // Register as slash command
  options: [ // Slash command options
    {
      name: 'user',
      description: 'User to target',
      type: 6, // USER type
      required: true
    }
  ],
  permissions: ['Administrator'], // Required permissions
  ownerOnly: false, // Restrict to owner
  
  async run(interaction, client) {
    // Your command logic here
  }
};

Interaction Handling

Create button handlers in interactions/buttons/:

// interactions/buttons/example.js
module.exports = {
  async execute(interaction, args, client) {
    await interaction.update({
      content: `You clicked with args: ${args.join(', ')}`,
      components: []
    });
  }
};

Events

Create custom event handlers in events/:

// events/guildCreate.js
module.exports = {
  name: 'guildCreate',
  once: false,
  
  async execute(guild, client) {
    console.log(`Joined new guild: ${guild.name}`);
  }
};

Built-in Commands 🔧

Command Description Slash Support
/help Advanced help menu with pagination
/botinfo Shows bot statistics and info
/serverinfo Shows server information
/ping Checks bot latency
/invite Gets bot invite link

Auto-modlog System 📝

When MODLOG_CHANNEL_ID is set, the bot automatically logs:

  • Member joins/leaves
  • Message deletions/edits
  • Bans/kicks
  • Channel changes

Example modlog entry: Modlog Example

Database Integration 🗃️

Access Mongoose directly through your commands:

async run(interaction, client) {
  const User = mongoose.model('User');
  const user = await User.findOne({ userId: interaction.user.id });
  // ... use user data
}

Configuration ⚙️

Customize initialization:

require('cwk-ds-tools')({
  commandsDir: './my-commands', // Custom commands directory
  eventsDir: './custom-events', // Custom events directory
  disableSlashCommands: false // Disable slash command registration
});

TypeScript Support 💻

Full type definitions included:

import { CommandInteraction } from 'discord.js';
import { CommandOptions } from 'cwk-ds-tools';

const command: CommandOptions = {
  name: 'ping',
  description: 'Ping command',
  run: async (interaction: CommandInteraction) => {
    await interaction.reply('Pong!');
  }
};

Contributing 🤝

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Support 💬

For help, join our Discord Server or open an issue on GitHub.

License 📄

This project is licensed under the MIT License - see the LICENSE file for details.


Made with ❤️ by Khanmanan | Buy me a coffee