discord-components-v2-masteruse
v1.0.3
Published
A TypeScript/JavaScript package for simplified Discord.js component interactions.
Maintainers
Readme
Discord Components V2
A TypeScript/JavaScript package for simplified Discord.js component interactions. This package abstracts away direct Discord API calls, making it easy for both beginners and advanced users to build interactive Discord bots.
Features
- Single unified import: access all components via one entry point
- Supports Buttons, Select Menus, Modals, and Discord Client setup
- Compatible with multiple versions of discord.js
- Beginner-friendly, robust for advanced use
Installation
npm install discord-components-v2-masteuser discord.jsUsage
Import the package entry point:
const { ComponentsV2 } = require('discord-components-v2-masteuser');
// or for ES Modules:
import { ComponentsV2 } from 'discord-components-v2-masteuser';Example: Basic Bot Setup
const client = new ComponentsV2.DiscordClient('YOUR_BOT_TOKEN');
client.onInteraction((interaction) => {
ComponentsV2.Button.handle(interaction, (i) => {
// Handle button click
});
ComponentsV2.SelectMenu.handle(interaction, (i) => {
// Handle select menu selection
});
ComponentsV2.Modal.handle(interaction, (i) => {
// Handle modal submit
});
});Creating a Button
const myButton = new ComponentsV2.Button('Click Me').setCustomId('my_button');Creating a Select Menu
const myMenu = new ComponentsV2.SelectMenu('Choose an option')
.addOption('Option 1', '1')
.addOption('Option 2', '2')
.setCustomId('my_menu');Creating a Modal
const myModal = new ComponentsV2.Modal('My Modal').setCustomId('my_modal');Implementation Guide
- Install dependencies as shown above.
- Import
ComponentsV2from the package entry point. - Initialize your Discord client and set up interaction handlers.
- Create and use components as needed.
Compatibility
- Works with discord.js v14 and above
- TypeScript and JavaScript supported
Best Practices
- Keep your interaction handlers simple and modular
- Use the provided classes to avoid direct API calls
- Refer to the examples for common patterns
License
MIT
For more advanced usage and troubleshooting, see the documentation or open an issue on GitHub.
