@gonzih/cc-discord 0.1.4 → 0.1.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.
Files changed (2) hide show
  1. package/dist/bot.js +12 -2
  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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gonzih/cc-discord",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Claude Code Discord bot — chat with Claude Code via Discord",
5
5
  "type": "module",
6
6
  "bin": {