# Fix "TypeError: BotBase.__init__() missing 1 required keyword-only argument: 'intents'" in discord.py 2

Yes. An agent adds the intents discord.py 2 requires, makes cog loading async, and proves offline that every cog and command still registers before opening a PR.

[Run this on Rush](https://cloud.getrush.ai/run/fix-bot-missing-intents-argument/discord-py/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

discord.py 2.0 made `intents` a required argument. A bot created the version 1 way, `commands.Bot(command_prefix=".")`, stops on that line with `TypeError: BotBase.__init__() missing 1 required keyword-only argument: 'intents'`, and `discord.Client()` fails the same way under its own class name. The usual one-line answer, passing `discord.Intents.default()`, makes the traceback disappear. It does not make a version 1 bot work, and the two things it leaves broken raise no error at all, which is why this message deserves more than the one line.

IEEE-VIT/concy-bot, a study bot with timers, alarms, reminders and a pomodoro command, is written the way most small bots from that period are. `requirements.txt` freezes `discord.py==1.7.3` together with its whole dependency tree, including `aiohttp==3.7.4.post0` and `yarl==1.6.3`. Line 7 of `bot.py` is `client = commands.Bot(command_prefix=".")`. Lines 24 to 26 walk the `cogs` directory at import time and call `client.load_extension(...)` for each of seven files, and every cog ends with a synchronous `def setup(client): client.add_cog(...)`. The `Procfile` starts it with `worker: python bot.py`, and no file fixes the Python version.

The agent starts by showing why staying on 1.7.3 is not an option, since that decides the size of the change. On Python 3.12 and 3.13 the frozen requirements do not install: the build of `yarl==1.6.3` fails. Installed without the frozen tree, discord.py 1.7.3 imports on 3.12 but not on 3.13, where its `aiohttp` 3.7 dependency does `import cgi`, a module that Python release removed. A host that moved to a current Python therefore pushes the bot to discord.py 2, and on 2.7.1 `python bot.py` stops at line 7 with the error in the title.

Then it fixes all three layers. It builds the intents explicitly and sets `intents.message_content = True`, because this bot answers prefix commands and `Intents.default()` leaves message content off; without it the bot logs in and ignores every `.command`. It moves the extension loop into an async `setup_hook` and awaits `load_extension`, because in version 2 that method and `add_cog` are coroutines: called the old way they return an object nobody runs, and the bot starts with no cogs. It turns each cog's `setup` into `async def` with `await client.add_cog(...)`. Finally it checks the result without a token, by constructing the bot, awaiting the loader and counting what registered. For this repository the right answer is 7 cogs and 10 commands, the built-in `help` included.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "This Discord bot fails at startup with TypeError: BotBase.__init__() missing 1 required keyword-only argument: 'intents' (or the same error for Client.__init__). It was written for discord.py 1.x. Read the dependency files, the Procfile or Dockerfile and any runtime file, and report the pinned discord.py version, whether its dependencies are frozen, and which Python version the host will use. In clean virtual environments, try to install the pinned requirements on that Python and on the newest Python, and report what fails, so the pull request can say whether staying on 1.x is possible. Then port the bot to the current discord.py 2 release. Create the intents explicitly: start from Intents.default(), and enable message_content if the bot uses prefix commands or reads message text, members if it uses member events or member lookups, and presences only if the code reads presence; list each privileged intent you enabled and the code that needs it. Move extension loading into an async setup_hook and await load_extension, unload_extension and reload_extension everywhere, including inside commands. Change every cog's setup function to async def and await add_cog. Search for other 1.x APIs (avatar_url, Embed.Empty, the client's logout method, guild region, permissions_in) and update each one found, with file and line. Do not use a real token and do not connect to Discord. Write a test that constructs the bot, awaits the extension loader, and asserts the exact set of cogs and command names; run it and include the output. Replace the frozen requirements with the direct dependencies, pinned to the versions you tested. Open a pull request that lists the changes, the intents that must be switched on in the Discord Developer Portal, and what could not be verified offline.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **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.
2. **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.
3. **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 the bot's entry file, one function at the bottom of every cog, and the requirements file. The description opens with the part that needs a human: the privileged intents the code now requests, each with the line that needs it, and the reminder that the same switches must be turned on for the application in the Discord Developer Portal. A bot that requests a privileged intent the portal has not granted is refused at login, so this step cannot be skipped.

Below that are the installed versions, the list of version 1 calls that were updated, and the output of the new test: the names of the cogs and commands that registered. A reviewer compares that list with the commands they know the bot has. A missing name means an extension did not load, the silent failure this port exists to prevent.

The description ends with what stayed unverified. The agent never logged in, so gateway behaviour, permissions in a real server and anything a command does after its first reply are for the reviewer to try with the real token in a test server before merging.

## Run it on every Linear issue labelled bot-down

Small bots have no CI, and the first sign of this failure is a user saying the bot is offline. If those reports land in Linear, give the bot's Project an automation with a `linear` trigger on `linear.issue.labeled` for the label you use, and a prompt that tells the agent to install the bot fresh, start it with a placeholder token far enough to see whether it fails before login, and port it if the failure is a discord.py 1 call. The issue is added after the prompt as text. The trigger needs a Linear connection on the account that owns the automation, made in the console under Settings → Connections.

For a team that runs several bots from one template, the port is the same in each. Send the request above once per repository with an API key and read each result from its session, or let the key's webhook report every `run.completed`.

## Why run it on Rush?

The dangerous part of this upgrade is what does not crash. A bot with default intents and an unawaited `load_extension` starts, shows as online and responds to nothing, and from the outside that looks like a Discord outage or a permissions problem. The only efficient check is to load the bot's extensions in a process and count the commands, and that is a small program someone has to write and run. The agent writes it as a test, runs it in a sandbox against the discord.py version it ported to, and puts the printed list in the pull request.

The sandbox also settles the question of whether to upgrade at all, with evidence. Trying the frozen requirements on two Python versions, and watching the build of an old `yarl` fail on both, is tedious and leaves debris in a local environment. In a run it is three commands whose output stays in the session, and the reviewer sees why the version 1 pin had to go instead of taking it on trust.

## Frequently asked questions

### Is passing discord.Intents.default() enough?

It removes the `TypeError`. For a bot with prefix commands it is not enough, because the default set leaves `message_content` off and the bot never sees the text of a command. Enable it in code and in the Developer Portal, or move the bot to slash commands, which do not need it.

### Why did my cogs stop loading after the upgrade, with no error?

In discord.py 2, `load_extension` and `add_cog` are coroutines. Called without `await` they do nothing except, at most, print a warning that a coroutine was never awaited. Each cog's `setup` must be `async def`, and extensions are loaded from an async `setup_hook`.

### Can I stay on discord.py 1.7.3?

Only on an older Python. In a check, a requirements file frozen around 1.7.3 failed to install on Python 3.12 and 3.13, and 1.7.3 with freshly resolved dependencies failed to import on 3.13. If your host chooses the Python version for you, the pin stops working the day the host moves.

### Does the agent need my bot token?

No, and the request tells it not to use one. Constructing the bot and loading its extensions needs no connection, and that is where this class of bug lives. Anything that needs a live gateway is listed in the pull request for you to test.

### Will it convert my prefix commands to slash commands?

Not in this run. The port keeps the bot's behaviour and command names as they are, so the pull request stays reviewable. Moving to slash commands changes how users invoke the bot and is better asked for as a separate task.

## More discord.py jobs

- [Review Pull Requests for a discord.py Bot](https://getrush.ai/run/review-pull-requests/discord-py/)
- [Write pytest Tests for a discord.py Bot](https://getrush.ai/run/write-pytest-tests/discord-py/)
- [Add Slash Commands to a discord.py Bot](https://getrush.ai/run/add-slash-command/discord-py/)

## More jobs like this: Fix a bug from an alert

- [Fix a Scrapy Spider That Stopped Returning Items](https://getrush.ai/run/fix-broken-spiders/scrapy/)
- [Fix "DeprecationWarning: Buffer() is deprecated" (DEP0005) in Node.js](https://getrush.ai/run/fix-buffer-deprecation-warning/nodejs/)
- [Fix "DeprecationWarning: Call to deprecated method findAll" in Beautiful Soup](https://getrush.ai/run/fix-call-to-deprecated-method-findall-warning/beautifulsoup4/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
