Skip to content

Config: migrate voicechannels.category.name to ID-based with helper #447

@lonix

Description

@lonix

Split out of #441 to keep PRs reviewable.

Problem

voicechannels.category.name stores the Discord category as a name instead of an ID. It's read in ~10 places across src/services/voice-channel-manager.ts and src/services/channel-initializer.ts, each doing a name-based lookup:

const categoryName = await configService.getString("voicechannels.category.name") ||
  await configService.getString("voice_channel.category_name") ||
  await configService.getString("VC_CATEGORY_NAME", "Dynamic Voice Channels");

const category = guild.channels.cache.find(
  (ch) => ch.type === ChannelType.GuildCategory && ch.name === categoryName,
);

Several sites also have legacy env-var fallback chains that need to come along. #439's selector UX needs this stored as an ID.

Proposed change

  1. Rename voicechannels.category.namevoicechannels.category_id in ConfigSchema, defaultConfig, settingsMetadata.
  2. Extract a helper (e.g., resolveManagedCategory(guild, configService): Promise<CategoryChannel | null>) that does an ID-based guild.channels.cache.get(categoryId) lookup and validates the channel type. Place it next to the manager or in a small new module.
  3. Replace every call site (~10) with the helper.
  4. Drop the legacy env-var fallback chains — those values get translated by the existing startupMigrator and won't be the source of truth post-migration.
  5. Hook into the shared name→ID startup migrator landing in the parent PR (the partial-implementation PR that lands amikool.role_id and voicetracking.announcements.channel_id) — add voicechannels.category.name to its rename list, with a CategoryChannel resolver.

Acceptance

  • voicechannels.category.name removed from ConfigSchema; voicechannels.category_id added.
  • All callers use the helper; no string "voicechannels.category.name" left in src/.
  • Migration successfully resolves stored names to IDs on first start after upgrade for deployments running pre-rename versions.
  • Existing tests pass; new tests cover the helper's happy path (returns the cached category) and the missing-ID path (returns null with a warning).

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions