vimcord 2.0.4 → 2.0.5
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.
- package/README.md +94 -24
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -65,6 +65,28 @@ await client.login();
|
|
|
65
65
|
|
|
66
66
|
`login()` uses `TOKEN`, or `TOKEN_DEV` when `client.$devMode` is true.
|
|
67
67
|
|
|
68
|
+
### Process CLI
|
|
69
|
+
|
|
70
|
+
Call `setupCLI()` once to enable promptless slash commands through the process stdin. This works in a local terminal and in hosting dashboards that provide a console command field.
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { GatewayIntentBits } from "discord.js";
|
|
74
|
+
import { setupCLI, Vimcord } from "vimcord";
|
|
75
|
+
|
|
76
|
+
setupCLI({
|
|
77
|
+
loaders: "auto" // "auto" | "always" | "never"
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const client = new Vimcord({
|
|
81
|
+
customId: "main",
|
|
82
|
+
client: {
|
|
83
|
+
intents: [GatewayIntentBits.Guilds]
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Clients participate by default once the process CLI is initialized. Set `globals.app.enableCLI` to `false` on clients that should remain unavailable to CLI commands. Enter `/help` in the process console to view commands.
|
|
89
|
+
|
|
68
90
|
### Modules And Command Dispatch
|
|
69
91
|
|
|
70
92
|
```ts
|
|
@@ -203,9 +225,9 @@ Command-local hooks override `client.globals.hooks`, and `client.globals.hooks`
|
|
|
203
225
|
### BetterEmbed
|
|
204
226
|
|
|
205
227
|
```ts
|
|
206
|
-
import { BetterEmbed,
|
|
228
|
+
import { BetterEmbed, defineGlobalUxConfig } from "vimcord";
|
|
207
229
|
|
|
208
|
-
|
|
230
|
+
defineGlobalUxConfig({
|
|
209
231
|
embedColor: "#5865F2",
|
|
210
232
|
embedColorDev: "#FF9D00"
|
|
211
233
|
});
|
|
@@ -213,7 +235,7 @@ defineGlobalToolConfig({
|
|
|
213
235
|
const embed = new BetterEmbed({
|
|
214
236
|
context: { interaction },
|
|
215
237
|
title: "Welcome, $USER_NAME",
|
|
216
|
-
description: ["Your avatar: $USER_AVATAR", "Today is $MONTH/$DAY/$YEAR"],
|
|
238
|
+
description: [showAvatar && "Your avatar: $USER_AVATAR", "", "Today is $MONTH/$DAY/$YEAR"],
|
|
217
239
|
timestamp: true
|
|
218
240
|
});
|
|
219
241
|
|
|
@@ -250,7 +272,8 @@ const intro = new BetterContainer().addText("## Help").addText("Choose a page be
|
|
|
250
272
|
const moderation = new BetterContainer().addText("## Moderation").addText("Ban, kick, and timeout commands.");
|
|
251
273
|
|
|
252
274
|
const paginator = new Paginator({
|
|
253
|
-
type: PaginationType.
|
|
275
|
+
type: PaginationType.LongSkip,
|
|
276
|
+
skipSize: 5,
|
|
254
277
|
idle: 60_000,
|
|
255
278
|
onTimeout: PaginationTimeout.DisableComponents
|
|
256
279
|
});
|
|
@@ -279,7 +302,9 @@ const result = await promptMessage(interaction, {
|
|
|
279
302
|
}),
|
|
280
303
|
participants: [interaction.user],
|
|
281
304
|
timeout: 30_000,
|
|
282
|
-
|
|
305
|
+
onConfirm: ResolveAction.DisableComponents,
|
|
306
|
+
onReject: ResolveAction.DisableComponents,
|
|
307
|
+
onTimeout: ResolveAction.DeleteMessage,
|
|
283
308
|
highlightSelectedButton: true
|
|
284
309
|
});
|
|
285
310
|
|
|
@@ -306,12 +331,19 @@ const modal = new BetterModal({ title: "Create Ticket" })
|
|
|
306
331
|
label: "Description",
|
|
307
332
|
style: TextInputStyle.Paragraph,
|
|
308
333
|
required: false
|
|
334
|
+
})
|
|
335
|
+
.addUserSelect({
|
|
336
|
+
customId: "assignees",
|
|
337
|
+
label: "Assignees",
|
|
338
|
+
maxValues: 3,
|
|
339
|
+
required: false
|
|
309
340
|
});
|
|
310
341
|
|
|
311
342
|
const result = await modal.showAndAwait(interaction, { timeout: 60_000 });
|
|
312
343
|
if (!result) return;
|
|
313
344
|
|
|
314
345
|
const subject = result.getField<string>("subject", true);
|
|
346
|
+
const assignees = result.getField("assignees", "getSelectedUsers");
|
|
315
347
|
|
|
316
348
|
await result.reply({
|
|
317
349
|
content: `Ticket created: ${subject}`,
|
|
@@ -370,10 +402,11 @@ Users.use(SoftDeletePlugin);
|
|
|
370
402
|
|
|
371
403
|
```ts
|
|
372
404
|
client.logger.success("Startup complete");
|
|
405
|
+
client.logger.debug("Only shown when verbose mode is enabled");
|
|
373
406
|
|
|
374
|
-
const
|
|
407
|
+
const loader = client.logger.loader("Syncing commands...");
|
|
375
408
|
await client.modules.commands.push();
|
|
376
|
-
|
|
409
|
+
loader.succeed("Commands synced");
|
|
377
410
|
```
|
|
378
411
|
|
|
379
412
|
---
|
|
@@ -396,8 +429,10 @@ stopLoader("Commands synced");
|
|
|
396
429
|
| `BetterModal` | Modal helper with V2 component support |
|
|
397
430
|
| `promptMessage`, `promptModal` | Confirmation prompt helpers |
|
|
398
431
|
| `dynaSend` | Send helper for interactions, channels, messages, members, and users |
|
|
399
|
-
| `
|
|
432
|
+
| `defineGlobalUxConfig` | Global UX defaults for embeds, collectors, paginator, and prompts |
|
|
400
433
|
| `defineGlobalCommandHooks` | Global command hooks used when modules do not define local hooks |
|
|
434
|
+
| `setupCLI` | Initializes the process-wide stdin CLI and its client targets |
|
|
435
|
+
| `CLILogger` | CLI-specific logger with target headers, groups, tables, styles, and loaders |
|
|
401
436
|
|
|
402
437
|
### Client Options
|
|
403
438
|
|
|
@@ -411,7 +446,7 @@ const client = new Vimcord({
|
|
|
411
446
|
app: {
|
|
412
447
|
name: "My Bot",
|
|
413
448
|
devMode: false,
|
|
414
|
-
|
|
449
|
+
enableCLI: true,
|
|
415
450
|
disableBanner: false
|
|
416
451
|
},
|
|
417
452
|
staff: {
|
|
@@ -426,7 +461,6 @@ const client = new Vimcord({
|
|
|
426
461
|
maxFailures: 2,
|
|
427
462
|
maxRefreshAttempts: 3
|
|
428
463
|
},
|
|
429
|
-
logLevel: "debug",
|
|
430
464
|
verbose: false
|
|
431
465
|
});
|
|
432
466
|
```
|
|
@@ -465,32 +499,70 @@ client.configure({
|
|
|
465
499
|
});
|
|
466
500
|
```
|
|
467
501
|
|
|
502
|
+
### Plugin CLI And Health Contributions
|
|
503
|
+
|
|
504
|
+
Plugin install hooks receive a typed context. Contributions remain scoped to that client and are removed automatically when the plugin unloads.
|
|
505
|
+
|
|
506
|
+
```ts
|
|
507
|
+
import type { VimcordPluginContext } from "vimcord";
|
|
508
|
+
import { VimcordPlugin } from "vimcord";
|
|
509
|
+
|
|
510
|
+
class ServicePlugin extends VimcordPlugin {
|
|
511
|
+
override name = "service";
|
|
512
|
+
override description = "Example service integration";
|
|
513
|
+
override version = "1.0.0";
|
|
514
|
+
|
|
515
|
+
constructor(private readonly service: { ping(): Promise<void> }) {
|
|
516
|
+
super();
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
override install({ cli, health }: VimcordPluginContext) {
|
|
520
|
+
cli.registerCommand({
|
|
521
|
+
name: "service-info",
|
|
522
|
+
description: "Displays service information.",
|
|
523
|
+
execute: ({ logger, client }) => logger.header("Service Info", client)
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
health.register({
|
|
527
|
+
id: "service",
|
|
528
|
+
label: "Service API",
|
|
529
|
+
check: async () => {
|
|
530
|
+
const startedAt = performance.now();
|
|
531
|
+
await this.service.ping();
|
|
532
|
+
return { status: "healthy", latencyMs: performance.now() - startedAt };
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
override uninstall() {}
|
|
538
|
+
}
|
|
539
|
+
```
|
|
540
|
+
|
|
468
541
|
---
|
|
469
542
|
|
|
470
543
|
## Examples
|
|
471
544
|
|
|
472
545
|
### Status Rotation
|
|
473
546
|
|
|
474
|
-
Status config is user-owned. Vimcord does not provide a default status rotation
|
|
547
|
+
Status config is user-owned. Vimcord does not provide a default status rotation, and a single profile applies in both
|
|
548
|
+
development and production.
|
|
475
549
|
|
|
476
550
|
```ts
|
|
477
551
|
import { ActivityType } from "discord.js";
|
|
478
552
|
|
|
479
553
|
await client.status.set({
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
]
|
|
487
|
-
},
|
|
488
|
-
development: {
|
|
489
|
-
activity: { name: "In development", type: ActivityType.Custom, status: "dnd" }
|
|
490
|
-
}
|
|
554
|
+
interval: 30_000,
|
|
555
|
+
randomize: true,
|
|
556
|
+
activity: [
|
|
557
|
+
{ name: "$GUILD_COUNT servers", type: ActivityType.Watching, status: "online" },
|
|
558
|
+
{ name: "Need help? Use /help", type: ActivityType.Custom, status: "online" }
|
|
559
|
+
]
|
|
491
560
|
});
|
|
492
561
|
```
|
|
493
562
|
|
|
563
|
+
Pass `production` and/or `development` profiles when their statuses differ. An omitted profile leaves that environment's
|
|
564
|
+
status blank; profiles do not fall back across environments.
|
|
565
|
+
|
|
494
566
|
### Command Dispatch Events
|
|
495
567
|
|
|
496
568
|
```ts
|
|
@@ -547,8 +619,6 @@ MONGO_URI_DEV=mongodb://localhost:27017/discord-bot-dev
|
|
|
547
619
|
|
|
548
620
|
Created by [**xsqu1znt**](https://github.com/xsqu1znt) with a simple goal: make Discord bot development enjoyable again.
|
|
549
621
|
|
|
550
|
-
Built on top of [qznt](https://github.com/xsqu1znt/qznt) for that extra bit of utility magic.
|
|
551
|
-
|
|
552
622
|
**License:** MIT
|
|
553
623
|
|
|
554
624
|
---
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vimcord",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"description": "A powerful and opinionated Discord.js wrapper.",
|
|
5
5
|
"author": "xsqu1znt",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"type": "module",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@vimcord/core": "0.1.
|
|
19
|
+
"@vimcord/core": "0.1.5"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
22
|
"build": "tsup",
|