@gonzih/cc-discord 0.1.4 → 0.1.6
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/bot.js +12 -2
- package/dist/index.js +5 -2
- package/package.json +1 -1
package/dist/bot.js
CHANGED
|
@@ -82,6 +82,16 @@ async function fetchAsBase64(url) {
|
|
|
82
82
|
}).on("error", reject);
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Resolve the Discord category ID to use as `parent` when creating new text channels.
|
|
87
|
+
* Priority: DISCORD_DEFAULT_CATEGORY_ID env var → first category named "Text Channels" → undefined.
|
|
88
|
+
*/
|
|
89
|
+
function resolveCategoryId(guild) {
|
|
90
|
+
if (process.env.DISCORD_DEFAULT_CATEGORY_ID)
|
|
91
|
+
return process.env.DISCORD_DEFAULT_CATEGORY_ID;
|
|
92
|
+
const category = guild.channels.cache.find((ch) => ch.type === ChannelType.GuildCategory && /text channels/i.test(ch.name));
|
|
93
|
+
return category?.id;
|
|
94
|
+
}
|
|
85
95
|
export class CcDiscordBot {
|
|
86
96
|
client;
|
|
87
97
|
sessions = new Map();
|
|
@@ -624,7 +634,7 @@ export class CcDiscordBot {
|
|
|
624
634
|
}
|
|
625
635
|
await interaction.deferReply();
|
|
626
636
|
try {
|
|
627
|
-
const newChannel = await guild.channels.create({ name: namespace, type: ChannelType.GuildText });
|
|
637
|
+
const newChannel = await guild.channels.create({ name: namespace, type: ChannelType.GuildText, parent: resolveCategoryId(guild) });
|
|
628
638
|
this.channelNamespaceMap.set(newChannel.id, { namespace, repoUrl });
|
|
629
639
|
this.opts.registerRoutedChannelId?.(namespace, newChannel.id);
|
|
630
640
|
await interaction.editReply(`Created <#${newChannel.id}> — messages there route to the ${repoUrl} meta-agent`);
|
|
@@ -762,7 +772,7 @@ export class CcDiscordBot {
|
|
|
762
772
|
}
|
|
763
773
|
let newChannel;
|
|
764
774
|
try {
|
|
765
|
-
newChannel = await guild.channels.create({ name: namespace, type: ChannelType.GuildText });
|
|
775
|
+
newChannel = await guild.channels.create({ name: namespace, type: ChannelType.GuildText, parent: resolveCategoryId(guild) });
|
|
766
776
|
}
|
|
767
777
|
catch (err) {
|
|
768
778
|
await channel.send(`Failed to create channel: ${err.message}`).catch(() => { });
|
package/dist/index.js
CHANGED
|
@@ -18,10 +18,13 @@
|
|
|
18
18
|
* CWD — working directory for Claude Code (default: process.cwd())
|
|
19
19
|
* DEFAULT_GITHUB_ORG — default GitHub org for #repo routing (default: gonzih)
|
|
20
20
|
*/
|
|
21
|
+
import { createRequire } from "node:module";
|
|
21
22
|
import { Redis } from "ioredis";
|
|
22
23
|
import { CcDiscordBot } from "./bot.js";
|
|
23
24
|
import { startNotifier } from "./notifier.js";
|
|
24
25
|
import { loadTokens } from "./tokens.js";
|
|
26
|
+
const require = createRequire(import.meta.url);
|
|
27
|
+
const { version } = require("../package.json");
|
|
25
28
|
function required(name) {
|
|
26
29
|
const val = process.env[name];
|
|
27
30
|
if (!val) {
|
|
@@ -71,10 +74,10 @@ sharedRedis.on("error", (err) => {
|
|
|
71
74
|
});
|
|
72
75
|
sharedRedis.once("ready", () => {
|
|
73
76
|
// Announce this version on Redis so other services can discover cc-discord
|
|
74
|
-
sharedRedis.set(`cca:meta:cc-discord:version`,
|
|
77
|
+
sharedRedis.set(`cca:meta:cc-discord:version`, version).catch((err) => {
|
|
75
78
|
console.warn("[redis] failed to write version:", err.message);
|
|
76
79
|
});
|
|
77
|
-
console.log(
|
|
80
|
+
console.log(`[cc-discord] version:reported ${version}`);
|
|
78
81
|
});
|
|
79
82
|
// Mutable placeholder closures — filled in once `bot` is created below
|
|
80
83
|
let getLastActiveChannelIdFn = () => undefined;
|