djs-next 1.0.0-dev.1 → 1.0.0-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of djs-next might be problematic. Click here for more details.
- package/README.md +61 -30
- package/bin/create-djs-next.js +78 -0
- package/dist/index.d.mts +57 -5
- package/dist/index.d.ts +57 -5
- package/dist/index.js +620 -256
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +620 -246
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +277 -68
- package/src/index.ts +4 -1
- package/src/plugins/dnxt.ts +215 -176
- package/src/templates/cjs.ts +11 -6
- package/src/templates/esm.ts +11 -4
- package/src/templates/ts.ts +11 -5
- package/src/types.ts +27 -2
- package/src/utils/PaginationBuilder.ts +94 -0
- package/src/utils/paginate.ts +32 -13
- package/src/utils/prompts.ts +76 -0
- package/test_payload.js +3 -0
- package/test_reply.js +4 -0
- package/tsup.config.ts +1 -1
- package/dist/cli.d.mts +0 -1
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +0 -344
- package/dist/cli.js.map +0 -1
- package/dist/cli.mjs +0 -321
- package/dist/cli.mjs.map +0 -1
- package/src/cli.ts +0 -203
package/README.md
CHANGED
|
@@ -13,17 +13,18 @@
|
|
|
13
13
|
## ✨ Features
|
|
14
14
|
|
|
15
15
|
- 📁 **Next.js File-Based Routing**: Auto-loads commands, events, components, and tasks natively. Supports Regex dynamic routes (e.g., `[id].ts` for components).
|
|
16
|
-
- 🛠️ **Native Developer Tools (`dnxt`)**: A comprehensive, built-in developer suite. Live JS evaluation,
|
|
16
|
+
- 🛠️ **Native Developer Tools (`dnxt`)**: A comprehensive, built-in developer suite. Live JS evaluation, remote shell execution, and instant Hot-Module Reloading!
|
|
17
17
|
- 🔄 **Hot Module Replacement (HMR)**: Live-reload your commands, events, and logic on save without ever dropping your Discord Gateway connection.
|
|
18
|
-
- 🗄️ **Strict Database Interop**:
|
|
18
|
+
- 🗄️ **Strict Database Interop**: Connect your ORM (Prisma, Mongoose) securely.
|
|
19
19
|
- 🌍 **Localization (i18n)**: Out-of-the-box native string translations.
|
|
20
20
|
- 🛡️ **Middleware Routing**: Global `beforeExecute` hooks for overarching permission checks and analytics.
|
|
21
|
-
- 🚦 **
|
|
21
|
+
- 🚦 **Persistent Cooldowns**: Connect custom cache adapters (like Redis) for global persistent cooldown tracking.
|
|
22
|
+
- 📄 **PaginationBuilder**: A built-in class for creating robust interactive pagination menus.
|
|
22
23
|
|
|
23
24
|
## 📦 Installation
|
|
24
25
|
|
|
25
26
|
```bash
|
|
26
|
-
npm install djs-next
|
|
27
|
+
npm install djs-next
|
|
27
28
|
```
|
|
28
29
|
*(Or use `pnpm`, `yarn`, or `bun`)*
|
|
29
30
|
|
|
@@ -44,20 +45,26 @@ If you prefer to start manually, here's how to bootstrap `djs-next`:
|
|
|
44
45
|
|
|
45
46
|
### 1. The Entry Point (`index.js`)
|
|
46
47
|
```javascript
|
|
47
|
-
require('
|
|
48
|
-
const { GatewayIntentBits } = require('discord.js');
|
|
49
|
-
const { DJSNextClient } = require('djs-next');
|
|
48
|
+
const { GatewayIntentBits, DJSNextClient } = require('djs-next');
|
|
50
49
|
const { PrismaClient } = require('@prisma/client'); // Optional Database
|
|
51
50
|
|
|
52
51
|
const db = new PrismaClient();
|
|
53
52
|
|
|
54
53
|
const client = new DJSNextClient({
|
|
55
54
|
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent],
|
|
56
|
-
developers: ['YOUR_DISCORD_ID'] // Required for Developer Tools
|
|
55
|
+
developers: ['YOUR_DISCORD_ID'], // Required for Developer Tools
|
|
56
|
+
|
|
57
|
+
// Explicit Framework Toggles
|
|
58
|
+
enableSlashCommands: true,
|
|
59
|
+
enableTextCommands: true,
|
|
60
|
+
enableMentionPrefix: true,
|
|
61
|
+
enableNoPrefix: false,
|
|
62
|
+
prefixes: ['!', '?'], // Standard prefixes
|
|
63
|
+
|
|
64
|
+
// Connect your database (Mongoose, Prisma, etc.)
|
|
65
|
+
db: db,
|
|
57
66
|
});
|
|
58
67
|
|
|
59
|
-
// Attach your database for global framework availability
|
|
60
|
-
client.db = db;
|
|
61
68
|
|
|
62
69
|
// Enable Hot-Module Reloading (HMR) for dev
|
|
63
70
|
client.enableHMR();
|
|
@@ -70,15 +77,22 @@ client.start(process.env.DISCORD_TOKEN);
|
|
|
70
77
|
```
|
|
71
78
|
|
|
72
79
|
### 2. Creating a Command
|
|
73
|
-
Drop a file into `src/commands/ping.js`. The framework reads it and registers it
|
|
80
|
+
Drop a file into `src/commands/ping.js`. The framework reads it and registers it for **both** Slash Commands AND normal text prefixes!
|
|
74
81
|
```javascript
|
|
75
82
|
/** @type {import('djs-next').FileCommand} */
|
|
76
83
|
module.exports = {
|
|
77
84
|
description: 'Replies with Pong!',
|
|
85
|
+
aliases: ['p'], // Works for text commands (e.g. !p)
|
|
78
86
|
cooldown: 5, // Automatically intercepts spammers
|
|
87
|
+
|
|
88
|
+
// Triggers on Slash Command: /ping
|
|
79
89
|
execute: async (interaction, client) => {
|
|
80
|
-
// client.db is strongly typed as your database (via JSDoc/TS config)
|
|
81
90
|
await interaction.reply('Pong! 🏓');
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
// Triggers on Text Prefix: !ping, @Bot ping, or no-prefix ping
|
|
94
|
+
executeText: async (message, args, client) => {
|
|
95
|
+
await message.reply('Pong from text! 🏓');
|
|
82
96
|
}
|
|
83
97
|
};
|
|
84
98
|
```
|
|
@@ -95,6 +109,25 @@ module.exports = {
|
|
|
95
109
|
await interaction.reply(`Banning user ${targetId}...`);
|
|
96
110
|
}
|
|
97
111
|
};
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### 4. Interactive Pagination
|
|
119
|
+
You no longer need to write complex collectors for simple pagination menus. `djs-next` ships with a `PaginationBuilder`:
|
|
120
|
+
```javascript
|
|
121
|
+
const { PaginationBuilder } = require('djs-next');
|
|
122
|
+
const { EmbedBuilder } = require('discord.js');
|
|
123
|
+
|
|
124
|
+
// Inside a command execute function:
|
|
125
|
+
const paginator = new PaginationBuilder()
|
|
126
|
+
.addPage(new EmbedBuilder().setDescription('Page 1'))
|
|
127
|
+
.addPage(new EmbedBuilder().setDescription('Page 2'))
|
|
128
|
+
.setTimeout(60000);
|
|
129
|
+
|
|
130
|
+
await paginator.build(interaction);
|
|
98
131
|
```
|
|
99
132
|
|
|
100
133
|
---
|
|
@@ -107,20 +140,18 @@ Because `djs-next` uses a global `<DB>` generic, you can natively bind any popul
|
|
|
107
140
|
|
|
108
141
|
```javascript
|
|
109
142
|
// index.js
|
|
110
|
-
require('dotenv').config();
|
|
111
143
|
const mongoose = require('mongoose');
|
|
112
|
-
const { DJSNextClient } = require('djs-next');
|
|
113
|
-
const { GatewayIntentBits } = require('discord.js');
|
|
144
|
+
const { DJSNextClient, GatewayIntentBits } = require('djs-next');
|
|
114
145
|
|
|
115
146
|
// Connect to Atlas
|
|
116
147
|
mongoose.connect(process.env.MONGO_URI);
|
|
117
148
|
|
|
118
149
|
// Initialize DJSNext
|
|
119
150
|
const client = new DJSNextClient({
|
|
120
|
-
intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages ]
|
|
151
|
+
intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages ],
|
|
152
|
+
db: mongoose
|
|
121
153
|
});
|
|
122
154
|
|
|
123
|
-
client.db = mongoose;
|
|
124
155
|
client.start(process.env.TOKEN);
|
|
125
156
|
```
|
|
126
157
|
|
|
@@ -143,18 +174,16 @@ module.exports = {
|
|
|
143
174
|
|
|
144
175
|
```javascript
|
|
145
176
|
// index.js
|
|
146
|
-
require('dotenv').config();
|
|
147
177
|
const { createClient } = require('@supabase/supabase-js');
|
|
148
|
-
const { DJSNextClient } = require('djs-next');
|
|
149
|
-
const { GatewayIntentBits } = require('discord.js');
|
|
178
|
+
const { DJSNextClient, GatewayIntentBits } = require('djs-next');
|
|
150
179
|
|
|
151
180
|
const supabase = createClient('https://xyz.supabase.co', process.env.SUPABASE_KEY);
|
|
152
181
|
|
|
153
182
|
const client = new DJSNextClient({
|
|
154
|
-
intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages ]
|
|
183
|
+
intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages ],
|
|
184
|
+
db: supabase
|
|
155
185
|
});
|
|
156
186
|
|
|
157
|
-
client.db = supabase;
|
|
158
187
|
client.start(process.env.TOKEN);
|
|
159
188
|
```
|
|
160
189
|
|
|
@@ -181,18 +210,15 @@ module.exports = {
|
|
|
181
210
|
|
|
182
211
|
| Command | Action |
|
|
183
212
|
| --- | --- |
|
|
184
|
-
| `dnxt js <code>` | Evaluates Javascript live with
|
|
185
|
-
| `dnxt sh <cmd>` | Executes raw shell/terminal code on your host machine
|
|
213
|
+
| `dnxt js <code>` | Evaluates Javascript live with async resolution. |
|
|
214
|
+
| `dnxt sh <cmd>` | Executes raw shell/terminal code on your host machine. |
|
|
186
215
|
| `dnxt git <cmd>` | Executes standard git workflows (e.g., `dnxt git pull`). |
|
|
187
|
-
| `dnxt
|
|
216
|
+
| `dnxt in <channelId> <text>`| Injects a message seamlessly into a specific channel as the bot. |
|
|
188
217
|
| `dnxt reload <target>` | Hot-swaps the internal cache. (e.g., `dnxt reload commands`, `dnxt reload all`). |
|
|
189
|
-
| `dnxt source <cmd>` | Directly `fs.readFileSync`s the underlying source code of an active command! |
|
|
190
218
|
| `dnxt debug <cmd>` | Executes Javascript while explicitly tracking the Node.js V8 Heap Memory Delta. |
|
|
191
|
-
| `dnxt tasks` | Views all running background `setInterval` tasks in the framework. |
|
|
192
|
-
| `dnxt cancel <task>` | Forcefully kills a background interval process. |
|
|
193
219
|
| `dnxt sync` | Manually forces a global Discord Slash Command synchronization. |
|
|
194
|
-
| `dnxt
|
|
195
|
-
| `dnxt
|
|
220
|
+
| `dnxt restart` | Safely spawns a new background process and shuts down the current one. |
|
|
221
|
+
| `dnxt stop` or `dnxt shutdown` | Fully disconnects the client and kills the Node process. |
|
|
196
222
|
| `dnxt` | Displays the Developer Dashboard tracking System RAM, Node Host status, and Process uptime. |
|
|
197
223
|
|
|
198
224
|
---
|
|
@@ -211,6 +237,11 @@ module.exports = {
|
|
|
211
237
|
components: 'src/components',
|
|
212
238
|
tasks: 'src/tasks',
|
|
213
239
|
locales: 'src/locales'
|
|
240
|
+
},
|
|
241
|
+
// Optional Redis or persistent cache adapter for cooldowns
|
|
242
|
+
cooldownAdapter: {
|
|
243
|
+
get: async (cmdId, userId) => { /* return timestamp or null */ },
|
|
244
|
+
set: async (cmdId, userId, expiration) => { /* save to db */ }
|
|
214
245
|
}
|
|
215
246
|
};
|
|
216
247
|
```
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
const projectDir = process.cwd();
|
|
7
|
+
|
|
8
|
+
console.log('🚀 Welcome to create-djs-next! Scaffolding your project...\n');
|
|
9
|
+
|
|
10
|
+
const dirsToCreate = [
|
|
11
|
+
'src/commands',
|
|
12
|
+
'src/events',
|
|
13
|
+
'src/components',
|
|
14
|
+
'src/tasks',
|
|
15
|
+
'src/locales'
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
for (const dir of dirsToCreate) {
|
|
19
|
+
const dirPath = path.join(projectDir, dir);
|
|
20
|
+
if (!fs.existsSync(dirPath)) {
|
|
21
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
22
|
+
console.log(`✅ Created directory: ${dir}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const envContent = `DISCORD_TOKEN=your_token_here\nCLIENT_ID=your_client_id\nGUILD_ID=your_dev_guild_id`;
|
|
27
|
+
const envPath = path.join(projectDir, '.env');
|
|
28
|
+
if (!fs.existsSync(envPath)) {
|
|
29
|
+
fs.writeFileSync(envPath, envContent);
|
|
30
|
+
console.log('✅ Created .env file');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const indexContent = `const { GatewayIntentBits, DJSNextClient } = require('djs-next');
|
|
34
|
+
|
|
35
|
+
const client = new DJSNextClient({
|
|
36
|
+
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent],
|
|
37
|
+
developers: ['YOUR_DISCORD_USER_ID'],
|
|
38
|
+
clientId: process.env.CLIENT_ID,
|
|
39
|
+
|
|
40
|
+
// Framework Toggles
|
|
41
|
+
enableSlashCommands: true,
|
|
42
|
+
enableTextCommands: true,
|
|
43
|
+
enableMentionPrefix: true,
|
|
44
|
+
enableNoPrefix: false,
|
|
45
|
+
prefixes: ['!', '?'],
|
|
46
|
+
|
|
47
|
+
// Custom Middleware
|
|
48
|
+
middleware: (interactionOrMessage, client) => {
|
|
49
|
+
return true; // Return false to block execution
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
// Configuration
|
|
53
|
+
config: {
|
|
54
|
+
devGuildId: process.env.GUILD_ID,
|
|
55
|
+
locales: ['en'],
|
|
56
|
+
defaultLocale: 'en',
|
|
57
|
+
responses: {
|
|
58
|
+
developerOnly: '⛔ This command is restricted to bot developers.',
|
|
59
|
+
guildOnly: '⛔ This command can only be used inside a server.',
|
|
60
|
+
cooldown: '⏳ You are on cooldown! Please wait {time}.',
|
|
61
|
+
missingPerms: '⛔ You lack permissions.',
|
|
62
|
+
errorBoundary: '❌ An unexpected error occurred.',
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
client.enableHMR();
|
|
68
|
+
client.enableDevTools('dnxt'); // Enable 'dnxt' prefix dev commands
|
|
69
|
+
client.start(process.env.DISCORD_TOKEN);
|
|
70
|
+
\`;
|
|
71
|
+
|
|
72
|
+
const indexPath = path.join(projectDir, 'index.js');
|
|
73
|
+
if (!fs.existsSync(indexPath)) {
|
|
74
|
+
fs.writeFileSync(indexPath, indexContent);
|
|
75
|
+
console.log('✅ Created index.js');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
console.log('\n🎉 Scaffolding complete! Run \`npm install djs-next\` and start coding!');
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ApplicationCommandOptionData, PermissionResolvable, ChatInputCommandInteraction, Client, AutocompleteInteraction, MessageComponentInteraction, ModalSubmitInteraction, ClientOptions, Interaction, ClientEvents, Collection, CommandInteraction, EmbedBuilder } from 'discord.js';
|
|
1
|
+
import { ApplicationCommandOptionData, PermissionResolvable, ChatInputCommandInteraction, Client, Message, AutocompleteInteraction, MessageComponentInteraction, ModalSubmitInteraction, ClientOptions, Interaction, ClientEvents, Collection, CommandInteraction, EmbedBuilder } from 'discord.js';
|
|
3
2
|
export * from 'discord.js';
|
|
4
3
|
|
|
4
|
+
interface CooldownAdapter {
|
|
5
|
+
get(commandId: string, userId: string): Promise<number | null> | number | null;
|
|
6
|
+
set(commandId: string, userId: string, expirationTime: number): Promise<void> | void;
|
|
7
|
+
}
|
|
5
8
|
interface DJSNextConfig {
|
|
6
9
|
devGuildId?: string;
|
|
10
|
+
errorLogChannelId?: string;
|
|
11
|
+
responses?: {
|
|
12
|
+
developerOnly?: string | null;
|
|
13
|
+
guildOnly?: string | null;
|
|
14
|
+
cooldown?: string | null;
|
|
15
|
+
missingPerms?: string | null;
|
|
16
|
+
errorBoundary?: string | null;
|
|
17
|
+
};
|
|
7
18
|
locales?: string[];
|
|
8
19
|
defaultLocale?: string;
|
|
9
20
|
directories?: {
|
|
@@ -13,6 +24,7 @@ interface DJSNextConfig {
|
|
|
13
24
|
tasks?: string;
|
|
14
25
|
locales?: string;
|
|
15
26
|
};
|
|
27
|
+
cooldownAdapter?: CooldownAdapter;
|
|
16
28
|
}
|
|
17
29
|
interface DJSNextClientOptions extends ClientOptions {
|
|
18
30
|
commandsDir?: string;
|
|
@@ -22,8 +34,14 @@ interface DJSNextClientOptions extends ClientOptions {
|
|
|
22
34
|
clientId?: string;
|
|
23
35
|
guildId?: string;
|
|
24
36
|
developers?: string[];
|
|
25
|
-
|
|
37
|
+
prefixes?: string[] | string;
|
|
38
|
+
enableSlashCommands?: boolean;
|
|
39
|
+
enableTextCommands?: boolean;
|
|
40
|
+
enableMentionPrefix?: boolean | string[];
|
|
41
|
+
enableNoPrefix?: boolean | string[];
|
|
42
|
+
middleware?: (interaction: Interaction | Message, client: Client) => Promise<boolean> | boolean;
|
|
26
43
|
config?: DJSNextConfig;
|
|
44
|
+
db?: any;
|
|
27
45
|
}
|
|
28
46
|
interface FileTask<DB = any> {
|
|
29
47
|
filepath?: string;
|
|
@@ -43,11 +61,18 @@ interface FileCommand<DB = any> {
|
|
|
43
61
|
botPermissions?: PermissionResolvable[];
|
|
44
62
|
developerOnly?: boolean;
|
|
45
63
|
guildOnly?: boolean;
|
|
64
|
+
aliases?: string[];
|
|
65
|
+
preconditions?: string[];
|
|
46
66
|
execute?: (interaction: ChatInputCommandInteraction, client: Client & {
|
|
47
67
|
db: DB;
|
|
48
68
|
t: Function;
|
|
49
69
|
config: DJSNextConfig;
|
|
50
70
|
}) => Promise<void> | void;
|
|
71
|
+
executeText?: (message: Message, args: string[], client: Client & {
|
|
72
|
+
db: DB;
|
|
73
|
+
t: Function;
|
|
74
|
+
config: DJSNextConfig;
|
|
75
|
+
}) => Promise<void> | void;
|
|
51
76
|
autocomplete?: (interaction: AutocompleteInteraction, client: Client & {
|
|
52
77
|
db: DB;
|
|
53
78
|
t: Function;
|
|
@@ -57,6 +82,7 @@ interface FileCommand<DB = any> {
|
|
|
57
82
|
interface FileComponent<DB = any> {
|
|
58
83
|
filepath?: string;
|
|
59
84
|
customId?: string;
|
|
85
|
+
preconditions?: string[];
|
|
60
86
|
execute: (interaction: MessageComponentInteraction | ModalSubmitInteraction, client: Client & {
|
|
61
87
|
db: DB;
|
|
62
88
|
t: Function;
|
|
@@ -94,16 +120,42 @@ declare class DJSNextClient<DB = any> extends Client {
|
|
|
94
120
|
private _guildId?;
|
|
95
121
|
private _developers;
|
|
96
122
|
private _middleware?;
|
|
123
|
+
private _prefixes;
|
|
124
|
+
private _enableSlashCommands;
|
|
125
|
+
private _enableTextCommands;
|
|
126
|
+
private _enableMentionPrefix;
|
|
127
|
+
private _enableNoPrefix;
|
|
97
128
|
constructor(options: DJSNextClientOptions);
|
|
98
129
|
private attachCoreListeners;
|
|
99
130
|
start(token: string): Promise<void>;
|
|
100
131
|
enableDevTools(prefix?: 'dnxt' | 'nxt'): void;
|
|
101
132
|
enableHMR(): Promise<void>;
|
|
133
|
+
private handleCommandError;
|
|
134
|
+
private handlePreconditions;
|
|
102
135
|
}
|
|
103
136
|
|
|
104
|
-
declare function paginate(
|
|
137
|
+
declare function paginate(context: Message | CommandInteraction | MessageComponentInteraction, pages: EmbedBuilder[], time?: number): Promise<Message<boolean> | undefined>;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Sends a confirmation prompt (Yes/No) to the user.
|
|
141
|
+
* @param context The message or interaction context.
|
|
142
|
+
* @param content The text or embed to display in the prompt.
|
|
143
|
+
* @param time Time to wait for a response in milliseconds.
|
|
144
|
+
* @returns Boolean indicating true for Yes, false for No, or null if timed out.
|
|
145
|
+
*/
|
|
146
|
+
declare function confirmPrompt(context: Message | CommandInteraction | MessageComponentInteraction, content: string | EmbedBuilder, time?: number): Promise<boolean | null>;
|
|
105
147
|
|
|
106
148
|
declare function loadConfig(): Promise<DJSNextConfig>;
|
|
107
149
|
declare function defineConfig(config: DJSNextConfig): DJSNextConfig;
|
|
108
150
|
|
|
109
|
-
|
|
151
|
+
declare class PaginationBuilder {
|
|
152
|
+
private pages;
|
|
153
|
+
private timeout;
|
|
154
|
+
constructor(pages?: EmbedBuilder[]);
|
|
155
|
+
addPage(embed: EmbedBuilder): this;
|
|
156
|
+
setPages(pages: EmbedBuilder[]): this;
|
|
157
|
+
setTimeout(ms: number): this;
|
|
158
|
+
build(target: CommandInteraction | Message): Promise<Message | null>;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export { type CooldownAdapter, DJSNextClient, type DJSNextClientOptions, type DJSNextConfig, type Event as DJSNextEvent, type FileCommand, type FileComponent, type FileTask, PaginationBuilder, confirmPrompt, defineConfig, getLocalesCache, loadConfig, loadLocales, paginate, translate };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ApplicationCommandOptionData, PermissionResolvable, ChatInputCommandInteraction, Client, AutocompleteInteraction, MessageComponentInteraction, ModalSubmitInteraction, ClientOptions, Interaction, ClientEvents, Collection, CommandInteraction, EmbedBuilder } from 'discord.js';
|
|
1
|
+
import { ApplicationCommandOptionData, PermissionResolvable, ChatInputCommandInteraction, Client, Message, AutocompleteInteraction, MessageComponentInteraction, ModalSubmitInteraction, ClientOptions, Interaction, ClientEvents, Collection, CommandInteraction, EmbedBuilder } from 'discord.js';
|
|
3
2
|
export * from 'discord.js';
|
|
4
3
|
|
|
4
|
+
interface CooldownAdapter {
|
|
5
|
+
get(commandId: string, userId: string): Promise<number | null> | number | null;
|
|
6
|
+
set(commandId: string, userId: string, expirationTime: number): Promise<void> | void;
|
|
7
|
+
}
|
|
5
8
|
interface DJSNextConfig {
|
|
6
9
|
devGuildId?: string;
|
|
10
|
+
errorLogChannelId?: string;
|
|
11
|
+
responses?: {
|
|
12
|
+
developerOnly?: string | null;
|
|
13
|
+
guildOnly?: string | null;
|
|
14
|
+
cooldown?: string | null;
|
|
15
|
+
missingPerms?: string | null;
|
|
16
|
+
errorBoundary?: string | null;
|
|
17
|
+
};
|
|
7
18
|
locales?: string[];
|
|
8
19
|
defaultLocale?: string;
|
|
9
20
|
directories?: {
|
|
@@ -13,6 +24,7 @@ interface DJSNextConfig {
|
|
|
13
24
|
tasks?: string;
|
|
14
25
|
locales?: string;
|
|
15
26
|
};
|
|
27
|
+
cooldownAdapter?: CooldownAdapter;
|
|
16
28
|
}
|
|
17
29
|
interface DJSNextClientOptions extends ClientOptions {
|
|
18
30
|
commandsDir?: string;
|
|
@@ -22,8 +34,14 @@ interface DJSNextClientOptions extends ClientOptions {
|
|
|
22
34
|
clientId?: string;
|
|
23
35
|
guildId?: string;
|
|
24
36
|
developers?: string[];
|
|
25
|
-
|
|
37
|
+
prefixes?: string[] | string;
|
|
38
|
+
enableSlashCommands?: boolean;
|
|
39
|
+
enableTextCommands?: boolean;
|
|
40
|
+
enableMentionPrefix?: boolean | string[];
|
|
41
|
+
enableNoPrefix?: boolean | string[];
|
|
42
|
+
middleware?: (interaction: Interaction | Message, client: Client) => Promise<boolean> | boolean;
|
|
26
43
|
config?: DJSNextConfig;
|
|
44
|
+
db?: any;
|
|
27
45
|
}
|
|
28
46
|
interface FileTask<DB = any> {
|
|
29
47
|
filepath?: string;
|
|
@@ -43,11 +61,18 @@ interface FileCommand<DB = any> {
|
|
|
43
61
|
botPermissions?: PermissionResolvable[];
|
|
44
62
|
developerOnly?: boolean;
|
|
45
63
|
guildOnly?: boolean;
|
|
64
|
+
aliases?: string[];
|
|
65
|
+
preconditions?: string[];
|
|
46
66
|
execute?: (interaction: ChatInputCommandInteraction, client: Client & {
|
|
47
67
|
db: DB;
|
|
48
68
|
t: Function;
|
|
49
69
|
config: DJSNextConfig;
|
|
50
70
|
}) => Promise<void> | void;
|
|
71
|
+
executeText?: (message: Message, args: string[], client: Client & {
|
|
72
|
+
db: DB;
|
|
73
|
+
t: Function;
|
|
74
|
+
config: DJSNextConfig;
|
|
75
|
+
}) => Promise<void> | void;
|
|
51
76
|
autocomplete?: (interaction: AutocompleteInteraction, client: Client & {
|
|
52
77
|
db: DB;
|
|
53
78
|
t: Function;
|
|
@@ -57,6 +82,7 @@ interface FileCommand<DB = any> {
|
|
|
57
82
|
interface FileComponent<DB = any> {
|
|
58
83
|
filepath?: string;
|
|
59
84
|
customId?: string;
|
|
85
|
+
preconditions?: string[];
|
|
60
86
|
execute: (interaction: MessageComponentInteraction | ModalSubmitInteraction, client: Client & {
|
|
61
87
|
db: DB;
|
|
62
88
|
t: Function;
|
|
@@ -94,16 +120,42 @@ declare class DJSNextClient<DB = any> extends Client {
|
|
|
94
120
|
private _guildId?;
|
|
95
121
|
private _developers;
|
|
96
122
|
private _middleware?;
|
|
123
|
+
private _prefixes;
|
|
124
|
+
private _enableSlashCommands;
|
|
125
|
+
private _enableTextCommands;
|
|
126
|
+
private _enableMentionPrefix;
|
|
127
|
+
private _enableNoPrefix;
|
|
97
128
|
constructor(options: DJSNextClientOptions);
|
|
98
129
|
private attachCoreListeners;
|
|
99
130
|
start(token: string): Promise<void>;
|
|
100
131
|
enableDevTools(prefix?: 'dnxt' | 'nxt'): void;
|
|
101
132
|
enableHMR(): Promise<void>;
|
|
133
|
+
private handleCommandError;
|
|
134
|
+
private handlePreconditions;
|
|
102
135
|
}
|
|
103
136
|
|
|
104
|
-
declare function paginate(
|
|
137
|
+
declare function paginate(context: Message | CommandInteraction | MessageComponentInteraction, pages: EmbedBuilder[], time?: number): Promise<Message<boolean> | undefined>;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Sends a confirmation prompt (Yes/No) to the user.
|
|
141
|
+
* @param context The message or interaction context.
|
|
142
|
+
* @param content The text or embed to display in the prompt.
|
|
143
|
+
* @param time Time to wait for a response in milliseconds.
|
|
144
|
+
* @returns Boolean indicating true for Yes, false for No, or null if timed out.
|
|
145
|
+
*/
|
|
146
|
+
declare function confirmPrompt(context: Message | CommandInteraction | MessageComponentInteraction, content: string | EmbedBuilder, time?: number): Promise<boolean | null>;
|
|
105
147
|
|
|
106
148
|
declare function loadConfig(): Promise<DJSNextConfig>;
|
|
107
149
|
declare function defineConfig(config: DJSNextConfig): DJSNextConfig;
|
|
108
150
|
|
|
109
|
-
|
|
151
|
+
declare class PaginationBuilder {
|
|
152
|
+
private pages;
|
|
153
|
+
private timeout;
|
|
154
|
+
constructor(pages?: EmbedBuilder[]);
|
|
155
|
+
addPage(embed: EmbedBuilder): this;
|
|
156
|
+
setPages(pages: EmbedBuilder[]): this;
|
|
157
|
+
setTimeout(ms: number): this;
|
|
158
|
+
build(target: CommandInteraction | Message): Promise<Message | null>;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export { type CooldownAdapter, DJSNextClient, type DJSNextClientOptions, type DJSNextConfig, type Event as DJSNextEvent, type FileCommand, type FileComponent, type FileTask, PaginationBuilder, confirmPrompt, defineConfig, getLocalesCache, loadConfig, loadLocales, paginate, translate };
|