clementine-agent 1.0.0 → 1.0.1
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/cli/setup.js +35 -0
- package/package.json +1 -1
package/dist/cli/setup.js
CHANGED
|
@@ -510,6 +510,41 @@ export async function runSetup() {
|
|
|
510
510
|
console.log();
|
|
511
511
|
console.log(` ${BOLD}${channel.name}${RESET}`);
|
|
512
512
|
await collectCredentials(channel.credentials, entries);
|
|
513
|
+
// After Discord credentials: generate invite URL and offer to open it
|
|
514
|
+
if (channelValue === 'discord' && entries['DISCORD_TOKEN']) {
|
|
515
|
+
try {
|
|
516
|
+
// Bot tokens are base64(app_id).timestamp.hmac — extract the app ID from the first segment
|
|
517
|
+
const appId = Buffer.from(entries['DISCORD_TOKEN'].split('.')[0], 'base64').toString();
|
|
518
|
+
if (/^\d{17,20}$/.test(appId)) {
|
|
519
|
+
// Permissions: Send Messages, Read Messages, Read Message History, Embed Links,
|
|
520
|
+
// Attach Files, Use Slash Commands, Add Reactions, Manage Messages
|
|
521
|
+
const perms = '277025770560';
|
|
522
|
+
const inviteUrl = `https://discord.com/oauth2/authorize?client_id=${appId}&scope=bot+applications.commands&permissions=${perms}`;
|
|
523
|
+
console.log();
|
|
524
|
+
console.log(` ${GREEN}${BOLD}Add your bot to your Discord server:${RESET}`);
|
|
525
|
+
console.log(` ${CYAN}${inviteUrl}${RESET}`);
|
|
526
|
+
console.log();
|
|
527
|
+
const shouldOpen = await confirm({
|
|
528
|
+
message: 'Open this link in your browser now?',
|
|
529
|
+
default: true,
|
|
530
|
+
});
|
|
531
|
+
if (shouldOpen) {
|
|
532
|
+
try {
|
|
533
|
+
const openCmd = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'start' : 'xdg-open';
|
|
534
|
+
execSync(`${openCmd} "${inviteUrl}"`);
|
|
535
|
+
console.log(` ${DIM}Authorize the bot in your browser, then come back here.${RESET}`);
|
|
536
|
+
await confirm({ message: 'Done? Press Enter to continue', default: true });
|
|
537
|
+
}
|
|
538
|
+
catch {
|
|
539
|
+
console.log(` ${DIM}Couldn't open browser — copy the link above and open it manually.${RESET}`);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
catch {
|
|
545
|
+
// Token format unexpected — skip invite URL, non-fatal
|
|
546
|
+
}
|
|
547
|
+
}
|
|
513
548
|
// Set webhook enabled flag
|
|
514
549
|
if (channelValue === 'webhook') {
|
|
515
550
|
entries['WEBHOOK_ENABLED'] = 'true';
|