djs-next 0.0.1 → 1.0.0-dev.2

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/dist/cli.mjs ADDED
@@ -0,0 +1,321 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/cli.ts
4
+ import fs from "fs";
5
+ import path from "path";
6
+ import { input, select, password } from "@inquirer/prompts";
7
+
8
+ // src/templates/ts.ts
9
+ var tsTemplates = {
10
+ index: `import { DJSNextClient, GatewayIntentBits } from 'djs-next';
11
+ import 'dotenv/config';
12
+
13
+ const client = new DJSNextClient({
14
+ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages],
15
+ commandsDir: './src/commands',
16
+ eventsDir: './src/events',
17
+ componentsDir: './src/components',
18
+ tasksDir: './src/tasks',
19
+ clientId: process.env.CLIENT_ID
20
+ });
21
+
22
+ client.start(process.env.DISCORD_TOKEN!);
23
+ `,
24
+ ping: `import { FileCommand } from 'djs-next';
25
+
26
+ export const command: FileCommand = {
27
+ description: 'Replies with Pong!',
28
+ execute: async (interaction) => {
29
+ await interaction.reply('Pong!');
30
+ }
31
+ };
32
+ `,
33
+ ready: `import { DJSNextEvent, Events } from 'djs-next';
34
+
35
+ export const event: DJSNextEvent<Events.ClientReady> = {
36
+ name: Events.ClientReady,
37
+ once: true,
38
+ execute: (client) => {
39
+ console.log('Ready! Logged in as ' + client.user?.tag);
40
+ }
41
+ };
42
+ `,
43
+ healthcheck: `import { FileTask } from 'djs-next';
44
+
45
+ export const task: FileTask = {
46
+ interval: 60000,
47
+ execute: async (client) => {
48
+ console.log('[Task] Healthcheck completed.');
49
+ }
50
+ };
51
+ `
52
+ };
53
+
54
+ // src/templates/esm.ts
55
+ var esmTemplates = {
56
+ index: `import { DJSNextClient, GatewayIntentBits } from 'djs-next';
57
+ import 'dotenv/config';
58
+
59
+ const client = new DJSNextClient({
60
+ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages],
61
+ commandsDir: './src/commands',
62
+ eventsDir: './src/events',
63
+ componentsDir: './src/components',
64
+ tasksDir: './src/tasks',
65
+ clientId: process.env.CLIENT_ID
66
+ });
67
+
68
+ client.start(process.env.DISCORD_TOKEN);
69
+ `,
70
+ ping: `export const command = {
71
+ description: 'Replies with Pong!',
72
+ execute: async (interaction) => {
73
+ await interaction.reply('Pong!');
74
+ }
75
+ };
76
+ `,
77
+ ready: `import { Events } from 'djs-next';
78
+
79
+ export const event = {
80
+ name: Events.ClientReady,
81
+ once: true,
82
+ execute: (client) => {
83
+ console.log('Ready! Logged in as ' + client.user?.tag);
84
+ }
85
+ };
86
+ `,
87
+ healthcheck: `export const task = {
88
+ interval: 60000,
89
+ execute: async (client) => {
90
+ console.log('[Task] Healthcheck completed.');
91
+ }
92
+ };
93
+ `
94
+ };
95
+
96
+ // src/templates/cjs.ts
97
+ var cjsTemplates = {
98
+ index: `const { DJSNextClient, GatewayIntentBits } = require('djs-next');
99
+ require('dotenv/config');
100
+
101
+ const client = new DJSNextClient({
102
+ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages],
103
+ commandsDir: './src/commands',
104
+ eventsDir: './src/events',
105
+ componentsDir: './src/components',
106
+ tasksDir: './src/tasks',
107
+ clientId: process.env.CLIENT_ID
108
+ });
109
+
110
+ client.start(process.env.DISCORD_TOKEN);
111
+ `,
112
+ ping: `module.exports = {
113
+ command: {
114
+ description: 'Replies with Pong!',
115
+ execute: async (interaction) => {
116
+ await interaction.reply('Pong!');
117
+ }
118
+ }
119
+ };
120
+ `,
121
+ ready: `const { Events } = require('djs-next');
122
+
123
+ module.exports = {
124
+ event: {
125
+ name: Events.ClientReady,
126
+ once: true,
127
+ execute: (client) => {
128
+ console.log('Ready! Logged in as ' + client.user?.tag);
129
+ }
130
+ }
131
+ };
132
+ `,
133
+ healthcheck: `module.exports = {
134
+ task: {
135
+ interval: 60000,
136
+ execute: async (client) => {
137
+ console.log('[Task] Healthcheck completed.');
138
+ }
139
+ }
140
+ };
141
+ `
142
+ };
143
+
144
+ // src/cli.ts
145
+ import pc from "picocolors";
146
+ import { execSync } from "child_process";
147
+ async function main() {
148
+ console.log(pc.bold(pc.blue("\n\u{1F680} Welcome to djs-next!\n")));
149
+ const userAgent = process.env.npm_config_user_agent || "";
150
+ let pm = "npm";
151
+ if (userAgent.startsWith("yarn")) pm = "yarn";
152
+ else if (userAgent.startsWith("pnpm")) pm = "pnpm";
153
+ else if (userAgent.startsWith("bun")) pm = "bun";
154
+ const args = process.argv.slice(2);
155
+ let projectName = args[0] || "";
156
+ if (!projectName || projectName === "init") {
157
+ projectName = await input({
158
+ message: "What is your project named?",
159
+ default: "my-bot",
160
+ validate: (value) => value.trim().length > 0 || "Project name is required"
161
+ });
162
+ }
163
+ const language = await select({
164
+ message: "Would you like to use TypeScript or JavaScript?",
165
+ choices: [
166
+ { name: "TypeScript", value: "ts" },
167
+ { name: "JavaScript", value: "js" }
168
+ ],
169
+ default: "ts"
170
+ });
171
+ const moduleSystem = await select({
172
+ message: "Would you like to use ES Modules or CommonJS?",
173
+ choices: [
174
+ { name: "ES Modules (import/export)", value: "esm" },
175
+ { name: "CommonJS (require/module.exports)", value: "cjs" }
176
+ ],
177
+ default: "esm"
178
+ });
179
+ const botToken = await password({
180
+ message: "What is your Discord Bot Token? (Leave empty to skip)",
181
+ mask: true
182
+ });
183
+ const clientId = await input({
184
+ message: "What is your Discord Client ID? (Leave empty to skip)"
185
+ });
186
+ const targetPath = path.resolve(process.cwd(), projectName);
187
+ if (fs.existsSync(targetPath)) {
188
+ console.error(pc.red(`
189
+ Directory "${projectName}" already exists.`));
190
+ process.exit(1);
191
+ }
192
+ console.log(pc.cyan(`
193
+ Scaffolding project in ${targetPath}...`));
194
+ fs.mkdirSync(targetPath, { recursive: true });
195
+ const isTS = language === "ts";
196
+ const isESM = moduleSystem === "esm";
197
+ const ext = isTS ? "ts" : "js";
198
+ let devScript = isTS ? "tsx watch src/index.ts" : "node --watch src/index.js";
199
+ let startScript = isTS ? "node dist/index.js" : "node src/index.js";
200
+ if (pm === "bun") {
201
+ devScript = `bun run --watch src/index.${ext}`;
202
+ startScript = `bun src/index.${ext}`;
203
+ }
204
+ const packageJson = {
205
+ name: projectName.toLowerCase().replace(/\\s+/g, "-"),
206
+ version: "1.0.0",
207
+ main: isTS ? "dist/index.js" : "src/index.js",
208
+ type: isESM ? "module" : "commonjs",
209
+ scripts: {
210
+ "dev": devScript,
211
+ "start": startScript
212
+ },
213
+ dependencies: {
214
+ "discord.js": "latest",
215
+ "djs-next": "latest",
216
+ "dotenv": "latest"
217
+ },
218
+ devDependencies: {}
219
+ };
220
+ if (isTS) {
221
+ packageJson.scripts.build = "tsc";
222
+ packageJson.devDependencies = {
223
+ "typescript": "latest",
224
+ "@types/node": "latest",
225
+ "tsx": "latest"
226
+ };
227
+ }
228
+ fs.writeFileSync(path.join(targetPath, "package.json"), JSON.stringify(packageJson, null, 2));
229
+ if (isTS) {
230
+ const tsconfig = {
231
+ compilerOptions: {
232
+ target: "ES2022",
233
+ module: isESM ? "NodeNext" : "CommonJS",
234
+ moduleResolution: isESM ? "NodeNext" : "Node",
235
+ strict: true,
236
+ esModuleInterop: true,
237
+ outDir: "./dist",
238
+ types: ["node"],
239
+ ignoreDeprecations: "5.0"
240
+ },
241
+ include: ["src/**/*"]
242
+ };
243
+ fs.writeFileSync(path.join(targetPath, "tsconfig.json"), JSON.stringify(tsconfig, null, 2));
244
+ }
245
+ fs.writeFileSync(path.join(targetPath, ".env"), `DISCORD_TOKEN=${botToken || "your_token_here"}
246
+ CLIENT_ID=${clientId || "your_client_id_here"}
247
+ `);
248
+ fs.writeFileSync(path.join(targetPath, ".gitignore"), `node_modules/
249
+ dist/
250
+ .env
251
+ .DS_Store
252
+ `);
253
+ const srcDir = path.join(targetPath, "src");
254
+ fs.mkdirSync(srcDir, { recursive: true });
255
+ fs.mkdirSync(path.join(srcDir, "commands"), { recursive: true });
256
+ fs.mkdirSync(path.join(srcDir, "events"), { recursive: true });
257
+ fs.mkdirSync(path.join(srcDir, "components", "buttons"), { recursive: true });
258
+ fs.mkdirSync(path.join(srcDir, "tasks"), { recursive: true });
259
+ if (isTS) {
260
+ fs.writeFileSync(path.join(srcDir, `index.${ext}`), tsTemplates.index);
261
+ } else if (isESM) {
262
+ fs.writeFileSync(path.join(srcDir, `index.${ext}`), esmTemplates.index);
263
+ } else {
264
+ fs.writeFileSync(path.join(srcDir, "index.js"), cjsTemplates.index);
265
+ }
266
+ if (isTS) {
267
+ fs.writeFileSync(path.join(srcDir, "commands", "ping.ts"), tsTemplates.ping);
268
+ } else if (isESM) {
269
+ fs.writeFileSync(path.join(srcDir, "commands", "ping.js"), esmTemplates.ping);
270
+ } else {
271
+ fs.writeFileSync(path.join(srcDir, "commands", "ping.js"), cjsTemplates.ping);
272
+ }
273
+ if (isTS) {
274
+ fs.writeFileSync(path.join(srcDir, "events", "ready.ts"), tsTemplates.ready);
275
+ } else if (isESM) {
276
+ fs.writeFileSync(path.join(srcDir, "events", "ready.js"), esmTemplates.ready);
277
+ } else {
278
+ fs.writeFileSync(path.join(srcDir, "events", "ready.js"), cjsTemplates.ready);
279
+ }
280
+ if (isTS) {
281
+ fs.writeFileSync(path.join(srcDir, "tasks", "healthcheck.ts"), tsTemplates.healthcheck);
282
+ } else if (isESM) {
283
+ fs.writeFileSync(path.join(srcDir, "tasks", "healthcheck.js"), esmTemplates.healthcheck);
284
+ } else {
285
+ fs.writeFileSync(path.join(srcDir, "tasks", "healthcheck.js"), cjsTemplates.healthcheck);
286
+ }
287
+ console.log(pc.cyan(`
288
+ Installing dependencies with ${pm}...`));
289
+ try {
290
+ execSync(`${pm} install`, { cwd: targetPath, stdio: "inherit" });
291
+ } catch (error) {
292
+ console.error(pc.red(`
293
+ Failed to install dependencies. Please run '${pm} install' manually.`));
294
+ }
295
+ console.log(pc.green(pc.bold(`
296
+ Success! Created ${projectName} at ${targetPath}`)));
297
+ console.log(`
298
+ Inside that directory, you can run several commands:`);
299
+ console.log(pc.cyan(`
300
+ ${pm} run dev`));
301
+ console.log(` Starts the development server with hot-reloading.`);
302
+ if (isTS) {
303
+ console.log(pc.cyan(`
304
+ ${pm} run build`));
305
+ console.log(` Compiles the TypeScript app into JavaScript.`);
306
+ }
307
+ console.log(pc.cyan(`
308
+ ${pm} start`));
309
+ console.log(` Starts the production server.`);
310
+ console.log(`
311
+ We suggest that you begin by typing:
312
+ `);
313
+ console.log(pc.cyan(` cd ${projectName}`));
314
+ console.log(pc.cyan(` ${pm} run dev
315
+ `));
316
+ }
317
+ main().catch((err) => {
318
+ console.error(pc.red("An unexpected error occurred:"), err);
319
+ process.exit(1);
320
+ });
321
+ //# sourceMappingURL=cli.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli.ts","../src/templates/ts.ts","../src/templates/esm.ts","../src/templates/cjs.ts"],"sourcesContent":["#!/usr/bin/env node\nimport fs from 'fs';\nimport path from 'path';\nimport { input, select, password } from '@inquirer/prompts';\nimport { spawnSync } from 'child_process';\nimport { tsTemplates } from './templates/ts.js';\nimport { esmTemplates } from './templates/esm.js';\nimport { cjsTemplates } from './templates/cjs.js';\nimport pc from 'picocolors';\nimport { execSync } from 'child_process';\n\nasync function main() {\n console.log(pc.bold(pc.blue('\\n🚀 Welcome to djs-next!\\n')));\n\n const userAgent = process.env.npm_config_user_agent || '';\n let pm = 'npm';\n if (userAgent.startsWith('yarn')) pm = 'yarn';\n else if (userAgent.startsWith('pnpm')) pm = 'pnpm';\n else if (userAgent.startsWith('bun')) pm = 'bun';\n\n const args = process.argv.slice(2);\n let projectName = args[0] || '';\n\n if (!projectName || projectName === 'init') {\n projectName = await input({\n message: 'What is your project named?',\n default: 'my-bot',\n validate: (value) => value.trim().length > 0 || 'Project name is required'\n });\n }\n\n const language = await select({\n message: 'Would you like to use TypeScript or JavaScript?',\n choices: [\n { name: 'TypeScript', value: 'ts' },\n { name: 'JavaScript', value: 'js' }\n ],\n default: 'ts'\n });\n\n const moduleSystem = await select({\n message: 'Would you like to use ES Modules or CommonJS?',\n choices: [\n { name: 'ES Modules (import/export)', value: 'esm' },\n { name: 'CommonJS (require/module.exports)', value: 'cjs' }\n ],\n default: 'esm'\n });\n\n const botToken = await password({\n message: 'What is your Discord Bot Token? (Leave empty to skip)',\n mask: true\n });\n\n const clientId = await input({\n message: 'What is your Discord Client ID? (Leave empty to skip)'\n });\n\n const targetPath = path.resolve(process.cwd(), projectName);\n\n if (fs.existsSync(targetPath)) {\n console.error(pc.red(`\\nDirectory \"${projectName}\" already exists.`));\n process.exit(1);\n }\n\n console.log(pc.cyan(`\\nScaffolding project in ${targetPath}...`));\n fs.mkdirSync(targetPath, { recursive: true });\n\n const isTS = language === 'ts';\n const isESM = moduleSystem === 'esm';\n const ext = isTS ? 'ts' : 'js';\n\n let devScript = isTS ? \"tsx watch src/index.ts\" : \"node --watch src/index.js\";\n let startScript = isTS ? \"node dist/index.js\" : \"node src/index.js\";\n \n if (pm === 'bun') {\n devScript = `bun run --watch src/index.${ext}`;\n startScript = `bun src/index.${ext}`;\n }\n\n const packageJson: any = {\n name: projectName.toLowerCase().replace(/\\\\s+/g, '-'),\n version: \"1.0.0\",\n main: isTS ? \"dist/index.js\" : \"src/index.js\",\n type: isESM ? \"module\" : \"commonjs\",\n scripts: {\n \"dev\": devScript,\n \"start\": startScript\n },\n dependencies: {\n \"discord.js\": \"latest\",\n \"djs-next\": \"latest\",\n \"dotenv\": \"latest\"\n },\n devDependencies: {}\n };\n\n if (isTS) {\n packageJson.scripts.build = \"tsc\";\n packageJson.devDependencies = {\n \"typescript\": \"latest\",\n \"@types/node\": \"latest\",\n \"tsx\": \"latest\"\n };\n }\n\n fs.writeFileSync(path.join(targetPath, 'package.json'), JSON.stringify(packageJson, null, 2));\n\n if (isTS) {\n const tsconfig = {\n compilerOptions: {\n target: \"ES2022\",\n module: isESM ? \"NodeNext\" : \"CommonJS\",\n moduleResolution: isESM ? \"NodeNext\" : \"Node\",\n strict: true,\n esModuleInterop: true,\n outDir: \"./dist\",\n types: [\"node\"],\n ignoreDeprecations: \"5.0\"\n },\n include: [\"src/**/*\"]\n };\n fs.writeFileSync(path.join(targetPath, 'tsconfig.json'), JSON.stringify(tsconfig, null, 2));\n }\n\n fs.writeFileSync(path.join(targetPath, '.env'), `DISCORD_TOKEN=${botToken || 'your_token_here'}\nCLIENT_ID=${clientId || 'your_client_id_here'}\n`);\n fs.writeFileSync(path.join(targetPath, '.gitignore'), `node_modules/\ndist/\n.env\n.DS_Store\n`);\n\n const srcDir = path.join(targetPath, 'src');\n fs.mkdirSync(srcDir, { recursive: true });\n fs.mkdirSync(path.join(srcDir, 'commands'), { recursive: true });\n fs.mkdirSync(path.join(srcDir, 'events'), { recursive: true });\n fs.mkdirSync(path.join(srcDir, 'components', 'buttons'), { recursive: true });\n fs.mkdirSync(path.join(srcDir, 'tasks'), { recursive: true });\n\n // Index File\n if (isTS) {\n fs.writeFileSync(path.join(srcDir, `index.${ext}`), tsTemplates.index);\n } else if (isESM) {\n fs.writeFileSync(path.join(srcDir, `index.${ext}`), esmTemplates.index);\n } else {\n fs.writeFileSync(path.join(srcDir, 'index.js'), cjsTemplates.index);\n }\n\n // Ping Command\n if (isTS) {\n fs.writeFileSync(path.join(srcDir, 'commands', 'ping.ts'), tsTemplates.ping);\n } else if (isESM) {\n fs.writeFileSync(path.join(srcDir, 'commands', 'ping.js'), esmTemplates.ping);\n } else {\n fs.writeFileSync(path.join(srcDir, 'commands', 'ping.js'), cjsTemplates.ping);\n }\n\n // Ready Event\n if (isTS) {\n fs.writeFileSync(path.join(srcDir, 'events', 'ready.ts'), tsTemplates.ready);\n } else if (isESM) {\n fs.writeFileSync(path.join(srcDir, 'events', 'ready.js'), esmTemplates.ready);\n } else {\n fs.writeFileSync(path.join(srcDir, 'events', 'ready.js'), cjsTemplates.ready);\n }\n\n // Healthcheck Task\n if (isTS) {\n fs.writeFileSync(path.join(srcDir, 'tasks', 'healthcheck.ts'), tsTemplates.healthcheck);\n } else if (isESM) {\n fs.writeFileSync(path.join(srcDir, 'tasks', 'healthcheck.js'), esmTemplates.healthcheck);\n } else {\n fs.writeFileSync(path.join(srcDir, 'tasks', 'healthcheck.js'), cjsTemplates.healthcheck);\n }\n\n console.log(pc.cyan(`\\nInstalling dependencies with ${pm}...`));\n try {\n execSync(`${pm} install`, { cwd: targetPath, stdio: 'inherit' });\n } catch (error) {\n console.error(pc.red(`\\nFailed to install dependencies. Please run '${pm} install' manually.`));\n }\n\n console.log(pc.green(pc.bold(`\\nSuccess! Created ${projectName} at ${targetPath}`)));\n console.log(`\\nInside that directory, you can run several commands:`);\n console.log(pc.cyan(`\\n ${pm} run dev`));\n console.log(` Starts the development server with hot-reloading.`);\n if (isTS) {\n console.log(pc.cyan(`\\n ${pm} run build`));\n console.log(` Compiles the TypeScript app into JavaScript.`);\n }\n console.log(pc.cyan(`\\n ${pm} start`));\n console.log(` Starts the production server.`);\n console.log(`\\nWe suggest that you begin by typing:\\n`);\n console.log(pc.cyan(` cd ${projectName}`));\n console.log(pc.cyan(` ${pm} run dev\\n`));\n}\n\nmain().catch((err) => {\n console.error(pc.red('An unexpected error occurred:'), err);\n process.exit(1);\n});\n","export const tsTemplates = {\n index: `import { DJSNextClient, GatewayIntentBits } from 'djs-next';\nimport 'dotenv/config';\n\nconst client = new DJSNextClient({\n intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages],\n commandsDir: './src/commands',\n eventsDir: './src/events',\n componentsDir: './src/components',\n tasksDir: './src/tasks',\n clientId: process.env.CLIENT_ID\n});\n\nclient.start(process.env.DISCORD_TOKEN!);\n`,\n\n ping: `import { FileCommand } from 'djs-next';\n\nexport const command: FileCommand = {\n description: 'Replies with Pong!',\n execute: async (interaction) => {\n await interaction.reply('Pong!');\n }\n};\n`,\n\n ready: `import { DJSNextEvent, Events } from 'djs-next';\n\nexport const event: DJSNextEvent<Events.ClientReady> = {\n name: Events.ClientReady,\n once: true,\n execute: (client) => {\n console.log('Ready! Logged in as ' + client.user?.tag);\n }\n};\n`,\n\n healthcheck: `import { FileTask } from 'djs-next';\n\nexport const task: FileTask = {\n interval: 60000,\n execute: async (client) => {\n console.log('[Task] Healthcheck completed.');\n }\n};\n`\n};\n","export const esmTemplates = {\n index: `import { DJSNextClient, GatewayIntentBits } from 'djs-next';\nimport 'dotenv/config';\n\nconst client = new DJSNextClient({\n intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages],\n commandsDir: './src/commands',\n eventsDir: './src/events',\n componentsDir: './src/components',\n tasksDir: './src/tasks',\n clientId: process.env.CLIENT_ID\n});\n\nclient.start(process.env.DISCORD_TOKEN);\n`,\n\n ping: `export const command = {\n description: 'Replies with Pong!',\n execute: async (interaction) => {\n await interaction.reply('Pong!');\n }\n};\n`,\n\n ready: `import { Events } from 'djs-next';\n\nexport const event = {\n name: Events.ClientReady,\n once: true,\n execute: (client) => {\n console.log('Ready! Logged in as ' + client.user?.tag);\n }\n};\n`,\n\n healthcheck: `export const task = {\n interval: 60000,\n execute: async (client) => {\n console.log('[Task] Healthcheck completed.');\n }\n};\n`\n};\n","export const cjsTemplates = {\n index: `const { DJSNextClient, GatewayIntentBits } = require('djs-next');\nrequire('dotenv/config');\n\nconst client = new DJSNextClient({\n intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages],\n commandsDir: './src/commands',\n eventsDir: './src/events',\n componentsDir: './src/components',\n tasksDir: './src/tasks',\n clientId: process.env.CLIENT_ID\n});\n\nclient.start(process.env.DISCORD_TOKEN);\n`,\n\n ping: `module.exports = {\n command: {\n description: 'Replies with Pong!',\n execute: async (interaction) => {\n await interaction.reply('Pong!');\n }\n }\n};\n`,\n\n ready: `const { Events } = require('djs-next');\n\nmodule.exports = {\n event: {\n name: Events.ClientReady,\n once: true,\n execute: (client) => {\n console.log('Ready! Logged in as ' + client.user?.tag);\n }\n }\n};\n`,\n\n healthcheck: `module.exports = {\n task: {\n interval: 60000,\n execute: async (client) => {\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AAK,QAAQ,WAAW,EAAE,CAAC;AAC1C,UAAQ,IAAI,GAAG,KAAK,KAAK,EAAE;AAAA,CAAY,CAAC;AAC1C;AAEA,KAAK,EAAE,MAAM,CAAC,QAAQ;AACpB,UAAQ,MAAM,GAAG,IAAI,+BAA+B,GAAG,GAAG;AAC1D,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
package/dist/index.d.mts CHANGED
@@ -1,20 +1,9 @@
1
+ import * as discord_js from 'discord.js';
1
2
  import { ApplicationCommandOptionData, PermissionResolvable, ChatInputCommandInteraction, Client, Message, AutocompleteInteraction, MessageComponentInteraction, ModalSubmitInteraction, ClientOptions, Interaction, ClientEvents, Collection, CommandInteraction, EmbedBuilder } from 'discord.js';
2
3
  export * from 'discord.js';
3
4
 
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
- }
8
5
  interface DJSNextConfig {
9
6
  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
- };
18
7
  locales?: string[];
19
8
  defaultLocale?: string;
20
9
  directories?: {
@@ -24,7 +13,6 @@ interface DJSNextConfig {
24
13
  tasks?: string;
25
14
  locales?: string;
26
15
  };
27
- cooldownAdapter?: CooldownAdapter;
28
16
  }
29
17
  interface DJSNextClientOptions extends ClientOptions {
30
18
  commandsDir?: string;
@@ -35,13 +23,9 @@ interface DJSNextClientOptions extends ClientOptions {
35
23
  guildId?: string;
36
24
  developers?: string[];
37
25
  prefixes?: string[] | string;
38
- enableSlashCommands?: boolean;
39
- enableTextCommands?: boolean;
40
- enableMentionPrefix?: boolean | string[];
41
- enableNoPrefix?: boolean | string[];
26
+ enableMentionPrefix?: boolean;
42
27
  middleware?: (interaction: Interaction | Message, client: Client) => Promise<boolean> | boolean;
43
28
  config?: DJSNextConfig;
44
- db?: any;
45
29
  }
46
30
  interface FileTask<DB = any> {
47
31
  filepath?: string;
@@ -62,7 +46,6 @@ interface FileCommand<DB = any> {
62
46
  developerOnly?: boolean;
63
47
  guildOnly?: boolean;
64
48
  aliases?: string[];
65
- preconditions?: string[];
66
49
  execute?: (interaction: ChatInputCommandInteraction, client: Client & {
67
50
  db: DB;
68
51
  t: Function;
@@ -82,7 +65,6 @@ interface FileCommand<DB = any> {
82
65
  interface FileComponent<DB = any> {
83
66
  filepath?: string;
84
67
  customId?: string;
85
- preconditions?: string[];
86
68
  execute: (interaction: MessageComponentInteraction | ModalSubmitInteraction, client: Client & {
87
69
  db: DB;
88
70
  t: Function;
@@ -121,41 +103,17 @@ declare class DJSNextClient<DB = any> extends Client {
121
103
  private _developers;
122
104
  private _middleware?;
123
105
  private _prefixes;
124
- private _enableSlashCommands;
125
- private _enableTextCommands;
126
106
  private _enableMentionPrefix;
127
- private _enableNoPrefix;
128
107
  constructor(options: DJSNextClientOptions);
129
108
  private attachCoreListeners;
130
109
  start(token: string): Promise<void>;
131
110
  enableDevTools(prefix?: 'dnxt' | 'nxt'): void;
132
111
  enableHMR(): Promise<void>;
133
- private handleCommandError;
134
- private handlePreconditions;
135
112
  }
136
113
 
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>;
114
+ declare function paginate(interaction: CommandInteraction | MessageComponentInteraction, pages: EmbedBuilder[], time?: number): Promise<discord_js.Message<boolean> | undefined>;
147
115
 
148
116
  declare function loadConfig(): Promise<DJSNextConfig>;
149
117
  declare function defineConfig(config: DJSNextConfig): DJSNextConfig;
150
118
 
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 };
119
+ export { DJSNextClient, type DJSNextClientOptions, type DJSNextConfig, type Event as DJSNextEvent, type FileCommand, type FileComponent, type FileTask, defineConfig, getLocalesCache, loadConfig, loadLocales, paginate, translate };
package/dist/index.d.ts CHANGED
@@ -1,20 +1,9 @@
1
+ import * as discord_js from 'discord.js';
1
2
  import { ApplicationCommandOptionData, PermissionResolvable, ChatInputCommandInteraction, Client, Message, AutocompleteInteraction, MessageComponentInteraction, ModalSubmitInteraction, ClientOptions, Interaction, ClientEvents, Collection, CommandInteraction, EmbedBuilder } from 'discord.js';
2
3
  export * from 'discord.js';
3
4
 
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
- }
8
5
  interface DJSNextConfig {
9
6
  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
- };
18
7
  locales?: string[];
19
8
  defaultLocale?: string;
20
9
  directories?: {
@@ -24,7 +13,6 @@ interface DJSNextConfig {
24
13
  tasks?: string;
25
14
  locales?: string;
26
15
  };
27
- cooldownAdapter?: CooldownAdapter;
28
16
  }
29
17
  interface DJSNextClientOptions extends ClientOptions {
30
18
  commandsDir?: string;
@@ -35,13 +23,9 @@ interface DJSNextClientOptions extends ClientOptions {
35
23
  guildId?: string;
36
24
  developers?: string[];
37
25
  prefixes?: string[] | string;
38
- enableSlashCommands?: boolean;
39
- enableTextCommands?: boolean;
40
- enableMentionPrefix?: boolean | string[];
41
- enableNoPrefix?: boolean | string[];
26
+ enableMentionPrefix?: boolean;
42
27
  middleware?: (interaction: Interaction | Message, client: Client) => Promise<boolean> | boolean;
43
28
  config?: DJSNextConfig;
44
- db?: any;
45
29
  }
46
30
  interface FileTask<DB = any> {
47
31
  filepath?: string;
@@ -62,7 +46,6 @@ interface FileCommand<DB = any> {
62
46
  developerOnly?: boolean;
63
47
  guildOnly?: boolean;
64
48
  aliases?: string[];
65
- preconditions?: string[];
66
49
  execute?: (interaction: ChatInputCommandInteraction, client: Client & {
67
50
  db: DB;
68
51
  t: Function;
@@ -82,7 +65,6 @@ interface FileCommand<DB = any> {
82
65
  interface FileComponent<DB = any> {
83
66
  filepath?: string;
84
67
  customId?: string;
85
- preconditions?: string[];
86
68
  execute: (interaction: MessageComponentInteraction | ModalSubmitInteraction, client: Client & {
87
69
  db: DB;
88
70
  t: Function;
@@ -121,41 +103,17 @@ declare class DJSNextClient<DB = any> extends Client {
121
103
  private _developers;
122
104
  private _middleware?;
123
105
  private _prefixes;
124
- private _enableSlashCommands;
125
- private _enableTextCommands;
126
106
  private _enableMentionPrefix;
127
- private _enableNoPrefix;
128
107
  constructor(options: DJSNextClientOptions);
129
108
  private attachCoreListeners;
130
109
  start(token: string): Promise<void>;
131
110
  enableDevTools(prefix?: 'dnxt' | 'nxt'): void;
132
111
  enableHMR(): Promise<void>;
133
- private handleCommandError;
134
- private handlePreconditions;
135
112
  }
136
113
 
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>;
114
+ declare function paginate(interaction: CommandInteraction | MessageComponentInteraction, pages: EmbedBuilder[], time?: number): Promise<discord_js.Message<boolean> | undefined>;
147
115
 
148
116
  declare function loadConfig(): Promise<DJSNextConfig>;
149
117
  declare function defineConfig(config: DJSNextConfig): DJSNextConfig;
150
118
 
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 };
119
+ export { DJSNextClient, type DJSNextClientOptions, type DJSNextConfig, type Event as DJSNextEvent, type FileCommand, type FileComponent, type FileTask, defineConfig, getLocalesCache, loadConfig, loadLocales, paginate, translate };