Updates and upgrading

How the bot stays up to date, and how to move an older deployment onto the current setup.

Your bot's repository holds only your settings. The bot itself is the ctrlaltbot npm package, so updating means moving to a newer version of that package.

Automatic updates #

Bots set up with the Deploy button update like this:

  1. When a new version is published, Dependabot opens a pull request in your bot's repository.
  2. For minor and patch versions, such as 1.1.2 to 1.1.3, the repository's auto-update workflow merges it automatically.
  3. Cloudflare rebuilds and redeploys the bot from the merged change.
  4. If the new version changes the slash commands, the bot updates them with Discord itself.

Major versions, such as 1 to 2, may need changes on your side, so they wait for you to merge them. Read the changelog first.

To check for updates now, open your repository's Insights → Dependency graph → Dependabot and select Check for updates.

Manual updates #

For bots deployed from your own machine:

bash
npm update ctrlaltbot
npx wrangler deploy

When an update needs a settings change #

Updates change the bot's code but not your wrangler.jsonc. When a release needs a settings change, its changelog entry says so. For example, 1.1.1 added the global_fetch_strictly_public compatibility flag for docs sites in the same Cloudflare account.

Upgrading from cad-discord #

Before version 1.1.0, the bot was called cad-discord. It was installed from a release archive, and its commands were registered by hand. To move a deployment onto ctrlaltbot without changing anything in Discord, keep the Worker's name. The bot's URL then stays the same, and its secrets stay attached.

  1. Make a folder from the template

    bash
    git clone https://github.com/ctrl-alt-doc/ctrlaltbot.git
    cp -r ctrlaltbot/template my-bot
    cd my-bot
    npm install
  2. Copy your settings across

    In the new wrangler.jsonc, set name, CAD_BASE_URL, and DISCORD_CLIENT_ID to the values from your old wrangler.jsonc. To keep each server's colour, give the storage binding your old namespace ID:

    jsonc
    "kv_namespaces": [{ "binding": "BRAND_SETTINGS", "id": "your-existing-namespace-id" }],

    The binding must be named BRAND_SETTINGS, even if your old one had a different name.

  3. Check the secrets

    bash
    npx wrangler secret list

    You need both DISCORD_PUBLIC_KEY and DISCORD_TOKEN. Older versions didn't use the token, so it may be missing. Add it with npx wrangler secret put DISCORD_TOKEN.

  4. Deploy

    bash
    npx wrangler deploy

    The bot registers its new commands, including /ask, the next time someone uses it.

  5. Remove the old server-only commands

    If your old setup had DISCORD_GUILD_ID in its .env, its commands were registered to one server. The new bot registers them for every server, so that server now shows each command twice. See Duplicate commands to remove the old copies.

  6. Turn on automatic updates (optional)

    Push the folder to a GitHub repository, then connect it in the Cloudflare dashboard under Workers & Pages → your Worker → Settings → Builds → Connect.