calabasas 0.19.6 → 0.19.8
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/dist/config.d.ts +8 -0
- package/dist/index.js +43 -4
- package/package.json +1 -1
package/dist/config.d.ts
CHANGED
|
@@ -78,11 +78,19 @@ export type IntentName =
|
|
|
78
78
|
| "AutoModerationConfig"
|
|
79
79
|
| "AutoModerationExecution";
|
|
80
80
|
|
|
81
|
+
export type ContextMenuDefinition = {
|
|
82
|
+
name: string;
|
|
83
|
+
type: "user" | "message";
|
|
84
|
+
defaultMemberPermissions?: string;
|
|
85
|
+
dmPermission?: boolean;
|
|
86
|
+
};
|
|
87
|
+
|
|
81
88
|
export type CalabasasConfig = {
|
|
82
89
|
intents?: IntentName[];
|
|
83
90
|
sync?: SyncConfig;
|
|
84
91
|
events?: EventConfig;
|
|
85
92
|
commands?: Record<string, CommandDefinition>;
|
|
93
|
+
contextMenus?: Record<string, ContextMenuDefinition>;
|
|
86
94
|
};
|
|
87
95
|
|
|
88
96
|
/**
|
package/dist/index.js
CHANGED
|
@@ -2222,6 +2222,12 @@ export default defineCalabasas({
|
|
|
2222
2222
|
// ],
|
|
2223
2223
|
// },
|
|
2224
2224
|
// },
|
|
2225
|
+
|
|
2226
|
+
// Context menus - right-click actions on users or messages
|
|
2227
|
+
// contextMenus: {
|
|
2228
|
+
// reportUser: { name: "Report User", type: "user" },
|
|
2229
|
+
// bookmarkMessage: { name: "Bookmark Message", type: "message" },
|
|
2230
|
+
// },
|
|
2225
2231
|
});
|
|
2226
2232
|
`;
|
|
2227
2233
|
async function init() {
|
|
@@ -2341,6 +2347,20 @@ async function push(options) {
|
|
|
2341
2347
|
const eventConfigs = Object.keys(calabasasConfig.events ?? {}).map((eventType) => ({ eventType }));
|
|
2342
2348
|
const commands = calabasasConfig.commands;
|
|
2343
2349
|
const commandNames = commands ? Object.keys(commands) : [];
|
|
2350
|
+
const contextMenus = calabasasConfig.contextMenus;
|
|
2351
|
+
const contextMenuNames = contextMenus ? Object.keys(contextMenus) : [];
|
|
2352
|
+
if (contextMenus) {
|
|
2353
|
+
const userMenus = Object.values(contextMenus).filter((m) => m.type === "user");
|
|
2354
|
+
const messageMenus = Object.values(contextMenus).filter((m) => m.type === "message");
|
|
2355
|
+
if (userMenus.length > 5) {
|
|
2356
|
+
console.error(`Error: Too many user context menus (${userMenus.length}). Discord allows a maximum of 5 user commands.`);
|
|
2357
|
+
process.exit(1);
|
|
2358
|
+
}
|
|
2359
|
+
if (messageMenus.length > 5) {
|
|
2360
|
+
console.error(`Error: Too many message context menus (${messageMenus.length}). Discord allows a maximum of 5 message commands.`);
|
|
2361
|
+
process.exit(1);
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2344
2364
|
const s = p4.spinner();
|
|
2345
2365
|
s.start(`Pushing config from ${options.config}...`);
|
|
2346
2366
|
if (resolved.isPlatformKey) {
|
|
@@ -2356,7 +2376,7 @@ async function push(options) {
|
|
|
2356
2376
|
invites: calabasasConfig.sync?.invites ?? false
|
|
2357
2377
|
},
|
|
2358
2378
|
eventConfigs,
|
|
2359
|
-
commands: calabasasConfig.commands ? JSON.stringify(calabasasConfig.commands) : undefined
|
|
2379
|
+
commands: calabasasConfig.commands || calabasasConfig.contextMenus ? JSON.stringify({ commands: calabasasConfig.commands ?? {}, contextMenus: calabasasConfig.contextMenus ?? {} }) : undefined
|
|
2360
2380
|
});
|
|
2361
2381
|
if (!configOk) {
|
|
2362
2382
|
s.stop("Push failed");
|
|
@@ -2388,7 +2408,7 @@ async function push(options) {
|
|
|
2388
2408
|
p4.cancel(`Error: ${error}`);
|
|
2389
2409
|
process.exit(1);
|
|
2390
2410
|
}
|
|
2391
|
-
if (commands && commandNames.length > 0) {
|
|
2411
|
+
if (commands && commandNames.length > 0 || contextMenus && contextMenuNames.length > 0) {
|
|
2392
2412
|
const cmdResponse = await fetch(`${apiUrl}/api/cli/command-config`, {
|
|
2393
2413
|
method: "POST",
|
|
2394
2414
|
headers: {
|
|
@@ -2397,7 +2417,7 @@ async function push(options) {
|
|
|
2397
2417
|
},
|
|
2398
2418
|
body: JSON.stringify({
|
|
2399
2419
|
botId,
|
|
2400
|
-
commands: JSON.stringify(commands)
|
|
2420
|
+
commands: JSON.stringify({ commands: commands ?? {}, contextMenus: contextMenus ?? {} })
|
|
2401
2421
|
})
|
|
2402
2422
|
});
|
|
2403
2423
|
if (!cmdResponse.ok) {
|
|
@@ -2471,13 +2491,18 @@ No event handlers configured.`;
|
|
|
2471
2491
|
|
|
2472
2492
|
Commands: ${commandNames.length} configured
|
|
2473
2493
|
${commandNames.map((name) => ` - /${name}`).join(`
|
|
2494
|
+
`)}` : "";
|
|
2495
|
+
const contextMenuSummary = contextMenuNames.length > 0 ? `
|
|
2496
|
+
|
|
2497
|
+
Context menus: ${contextMenuNames.length} configured
|
|
2498
|
+
${contextMenuNames.map((name) => ` - ${contextMenus[name].name} (${contextMenus[name].type})`).join(`
|
|
2474
2499
|
`)}` : "";
|
|
2475
2500
|
const intentsSummary = intents && intents.length > 0 ? `
|
|
2476
2501
|
|
|
2477
2502
|
Intents: ${intents.length} configured
|
|
2478
2503
|
${intents.map((name) => ` - ${name}`).join(`
|
|
2479
2504
|
`)}` : "";
|
|
2480
|
-
p4.note(syncSummary + eventSummary + commandSummary + intentsSummary, "Sync settings");
|
|
2505
|
+
p4.note(syncSummary + eventSummary + commandSummary + contextMenuSummary + intentsSummary, "Sync settings");
|
|
2481
2506
|
p4.outro("Config pushed successfully!");
|
|
2482
2507
|
}
|
|
2483
2508
|
|
|
@@ -7425,6 +7450,20 @@ ${eventLines.join(`
|
|
|
7425
7450
|
});
|
|
7426
7451
|
sections.push(` commands: {
|
|
7427
7452
|
${commandLines.join(`
|
|
7453
|
+
`)}
|
|
7454
|
+
},`);
|
|
7455
|
+
}
|
|
7456
|
+
}
|
|
7457
|
+
if (config.contextMenus) {
|
|
7458
|
+
const menuKeys = Object.keys(config.contextMenus);
|
|
7459
|
+
if (menuKeys.length > 0) {
|
|
7460
|
+
const menuLines = menuKeys.map((name) => {
|
|
7461
|
+
const def = config.contextMenus[name];
|
|
7462
|
+
const serialized = serializeValue(def, 2);
|
|
7463
|
+
return ` ${name}: ${serialized},`;
|
|
7464
|
+
});
|
|
7465
|
+
sections.push(` contextMenus: {
|
|
7466
|
+
${menuLines.join(`
|
|
7428
7467
|
`)}
|
|
7429
7468
|
},`);
|
|
7430
7469
|
}
|