What the agent does
discord.js 14 removed the Intents export. A bot written for 13 opens with const {Client, Collection, Intents} = require('discord.js') and builds its client with new Client({intents: [Intents.FLAGS.GUILDS]}); on 14.28.1 Intents is undefined, so the second line throws TypeError: Cannot read properties of followed by undefined (reading 'FLAGS') before the bot logs in. The only exports with intent in the name are now GatewayIntentBits and IntentsBitField, and GatewayIntentBits.Guilds is the same bit, 1, that Intents.FLAGS.GUILDS was.
In a bot like lawalbolaji/Discord-bot-QR-code-generator, package.json asks for discord.js ^13.3.1 beside @discordjs/builders ^0.8.2, @discordjs/rest ^0.1.0-canary.0 and discord-api-types ^0.24.0, with the lockfile resolving discord.js 13.3.1 and engines naming Node 17.0.1. index.js line 5 is the import, line 8 the client, and line 30 filters events with interaction.isCommand(). commands/ping.js and commands/qr.js build their definitions with SlashCommandBuilder from @discordjs/builders; deployCommands.js registers them with REST from @discordjs/rest at version 9 and Routes.applicationGuildCommands from discord-api-types/v9. The one test, tests/googleQR.test.js, covers the URL builder with mocha and never touches Discord.
The agent reproduces both sides without a token. On the lockfile's 13.3.1, node index.js reaches client.login and stops with Error [TOKEN_INVALID]: An invalid token was provided, which is as far as a bot can get without credentials; after npm install discord.js@14 the same command dies on line 8 with the TypeError. It then reads what 14 exports: MessageEmbed is gone and EmbedBuilder exists, REST, Routes and SlashCommandBuilder are re-exported from discord.js itself, Events.InteractionCreate names the event string, isChatInputCommand sits beside isCommand, and the bundled REST defaults to API version 10. The package's engines field asks for Node 18 or newer.
The port touches three files. index.js imports GatewayIntentBits, passes [GatewayIntentBits.Guilds], and checks interaction.isChatInputCommand(). deployCommands.js drops the three sidecar packages for the REST and Routes that discord.js 14 ships, and the two command files import SlashCommandBuilder from the same place, so the four packages that had to move in step become one. package.json loses @discordjs/builders, @discordjs/rest and discord-api-types and raises engines to 18. With the port applied on a copy, node index.js runs to the same token check it reached on 13, now reported as DiscordjsError [TokenInvalid], which proves the startup path loads; the mocha test still passes on both versions because it never imports discord.js.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "This Discord bot crashes at startup on discord.js 14 with a TypeError reading FLAGS, because the Intents export is gone. In a clean install from the lockfile, run node index.js with no token and record where it stops; then install discord.js 14, run it again and capture the TypeError with its line. Read what the installed 14 release exports rather than working from memory, and port the bot: GatewayIntentBits in place of Intents.FLAGS, isChatInputCommand in place of isCommand, EmbedBuilder in place of MessageEmbed if used, and REST, Routes and SlashCommandBuilder imported from discord.js instead of @discordjs/builders, @discordjs/rest and discord-api-types. Remove those three packages from package.json and set engines to the Node range discord.js 14 requires. Do not log in to Discord and do not register commands. Show that node index.js on 14 now reaches the token check, run the existing tests, and open a pull request listing each renamed export with file and line and both startup transcripts.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
A pull request that changes index.js, deployCommands.js, each command file and package.json with its lockfile. The description opens with two startup transcripts: the TypeError on line 8 before the port, and the run after it that reaches the token check on discord.js 14. A table lists every export that moved, the file and line it was used on, and its 14 name.
The session's record keeps both installs, each node index.js run and the mocha output. A reviewer who wants to confirm the registration script still resolves reads the transcript's node -e check that REST and Routes load from discord.js, since the script itself is not run without credentials.
Before merging, a reviewer checks that the intents list only grew by rename and not by scope, that the bot's host runs the Node release engines now asks for, and that any ephemeral: true reply or embed in the command files was handled in the same pass or listed as a follow-up.
Run it on every Dependabot pull request for discord.js
The crash arrives as a dependency bump, not as an alert, so the right time to run this is when the bump is opened. A bot sender never fires an automation's github trigger, so give the automation a webhook trigger and add a workflow step on the bump that runs when its title names discord.js and posts the pull request number to the trigger's URL with Authorization: Bearer and the trigger's secret; the event lands after the prompt, and the run ports the bot against the exact release in the pull request's lockfile and pushes the port onto the same branch or opens its own.
From your own server the same request goes to POST /o/{org}/sessions with the repository in resources. Give it a request_id that is a UUID v5 of the pull request number, so a retried delivery returns the run that already started instead of opening a second pull request.
The use case this job follows, with its automation and trigger: Fix a bug from an alert.
Why run it on Rush?
A major-version port is cheap to type and expensive to trust: the proof is two installs, two startup runs and a read of the installed package's exports, not a changelog. In a Rush sandbox the agent does that on its own disk with no bot token in reach, keeps both transcripts, and the machine is gone when the run ends; nothing logs in to Discord and no command is registered against a live guild.
What comes back is checkable: the transcript holds the exact line that threw, the exports read from the installed release and the run that got past it. A team with several bots on the same template starts one run per repository with the same request, up to the key's max_concurrent limit at once, and the rest queue.
Frequently asked questions
Why did the bot stop starting after npm install?
Because a caret range on discord.js ^13.3.1 never moves to 14; this happens when someone bumps the range or runs npm install discord.js@latest. The Intents class the 13 code destructures is absent in 14, so the property read on the next line throws before client.login runs.
What replaced Intents.FLAGS.GUILDS?
GatewayIntentBits.Guilds, with the same bit value of 1. The agent reads the installed release's exports rather than a tutorial, so if your bot uses more flags each one is mapped from what the package actually exports and the table in the pull request shows the pair.
Do I still need @discordjs/builders, @discordjs/rest and discord-api-types?
Not as direct dependencies. discord.js 14 re-exports SlashCommandBuilder, REST and Routes, and its bundled REST defaults to API version 10. The pull request imports them from discord.js and removes the three packages, so one version bump covers what used to be four.
Can the agent test the bot without my token?
Up to the token check. Without credentials, discord.js 13 and 14 both stop at client.login with an invalid-token error, and reaching that point on 14 shows the startup code loads. The agent never logs in and never calls the registration script; the pull request says so.
Does isCommand still exist in 14?
Yes, on the installed release both isCommand and isChatInputCommand exist. The agent switches to isChatInputCommand because the handler only serves slash commands and the narrower check is what 14's own examples use; it notes the change rather than hiding it in the rename table.