discord-components-v2-masteruse
Version:
A TypeScript/JavaScript package for simplified Discord.js component interactions.
85 lines (64 loc) • 2.34 kB
Markdown
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.
- 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
```bash
npm install discord-components-v2-masteuser discord.js
```
Import the package entry point:
```typescript
const { ComponentsV2 } = require('discord-components-v2-masteuser');
// or for ES Modules:
import { ComponentsV2 } from 'discord-components-v2-masteuser';
```
```typescript
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
});
});
```
```typescript
const myButton = new ComponentsV2.Button('Click Me').setCustomId('my_button');
```
```typescript
const myMenu = new ComponentsV2.SelectMenu('Choose an option')
.addOption('Option 1', '1')
.addOption('Option 2', '2')
.setCustomId('my_menu');
```
```typescript
const myModal = new ComponentsV2.Modal('My Modal').setCustomId('my_modal');
```
1. Install dependencies as shown above.
2. Import `ComponentsV2` from the package entry point.
3. Initialize your Discord client and set up interaction handlers.
4. Create and use components as needed.
- Works with discord.js v14 and above
- TypeScript and JavaScript supported
- Keep your interaction handlers simple and modular
- Use the provided classes to avoid direct API calls
- Refer to the examples for common patterns
MIT
---
For more advanced usage and troubleshooting, see the documentation or open an issue on GitHub.
A TypeScript/JavaScript package