Skip to content

Config: migrate name-based Discord references to IDs with startup migration #441

@lonix

Description

@lonix

Problem

Several config keys store Discord entity references as names rather than IDs:

  • voicechannels.category.name — text-channel category lookup by name.
  • voicetracking.announcements.channel (default "voice-stats") — channel by name.
  • amikool.role.name — role lookup by name.

voicechannels.lobby.name / voicechannels.lobby.offlinename are cosmetic display strings the bot sets on managed channels (not lookups) and should stay as names, but their descriptions should clarify that.

Name-based references break in two ways:

  1. Names aren't unique — two roles named "Mods" or two categories named "Voice" produce undefined lookup behavior.
  2. Names aren't selector-friendly. WebUI: dropdown selectors for channel/category/role config keys (replace freetext) #439 plans to render channel/role/category keys as <select> dropdowns populated from the guild cache; that fundamentally relies on the stored value being an ID. Without this migration, those specific keys can't actually be dropdowns.

Proposed change

  1. Rename the keys (and update all reads):
    • voicechannels.category.namevoicechannels.category_id
    • voicetracking.announcements.channelvoicetracking.announcements.channel_id
    • amikool.role.nameamikool.role_id
  2. Leave voicechannels.lobby.name / lobby.offlinename alone but tighten their descriptions in settingsMetadata.
  3. Startup migration: for each renamed key, on first start after the upgrade, look up the named entity in the guild cache. If found, store the ID under the new key and delete the old key. If not found, log a warning and leave the new key empty so the operator notices.
  4. Update settingsMetadata for the new keys; remove old entries.

Acceptance

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