Fix discord.py "missing 1 required keyword-only argument: 'intents'"
Your code was written for discord.py 1.x, but discord.py 2.x is installed. Since 2.0 you must pass intents when you create the client or bot.
The bot stops before it even logs in, with one of these (tested on discord.py 2.7.1):
TypeError: Client.__init__() missing 1 required keyword-only argument: 'intents'TypeError: BotBase.__init__() missing 1 required keyword-only argument: 'intents'On older Python versions the start of the message is just __init__(). It's the same error.
Why it happens #
discord.py 2.0 made the intents argument required for discord.Client, commands.Bot and their AutoSharded versions. In 1.x it was optional and quietly defaulted to Intents.default(). Tutorials and templates from before 2022 still show:
client = discord.Client()
bot = commands.Bot(command_prefix="!")When pip install discord.py (or your host) installs the current 2.x version, that line fails.
How to fix it #
- Create an Intents object and pass it in, as below.
Intents.default()is everything except the three privileged intents. - Add privileged intents only if you use them:
message_contentfor prefix commands or reading message text,membersfor join events and member lists,presencesfor statuses. - Turn the same ones on in the Developer Portal (your app → Bot → Privileged Gateway Intents). If you skip this you'll get
PrivilegedIntentsRequirednext; see that fix. - Restart the bot.
import os
import discord
from discord.ext import commands
from dotenv import load_dotenv
load_dotenv()
intents = discord.Intents.default()
intents.message_content = True # only if you use prefix commands or read message text
# intents.members = True # only if you need member join events or member lists
bot = commands.Bot(command_prefix="!", intents=intents)
@bot.event
async def on_ready():
print(f"Logged in as {bot.user}")
@bot.command()
async def ping(ctx: commands.Context):
await ctx.send("pong")
bot.run(os.getenv("DISCORD_TOKEN"))For a plain client it's the same idea: client = discord.Client(intents=discord.Intents.default()).
Other 1.x → 2.x changes that break next #
Once intents are fixed, old code often hits these:
- Extensions and cogs load asynchronously.
bot.load_extension()andbot.add_cog()must be awaited, and an extension'ssetupfunction must beasync def. Load them insetup_hook:
import discord
from discord.ext import commands
class MyBot(commands.Bot):
async def setup_hook(self):
await self.load_extension("cogs.music") # was bot.load_extension(...) in 1.x
# in cogs/music.py
class Music(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
async def setup(bot: commands.Bot): # was def setup(bot) in 1.x
await bot.add_cog(Music(bot))- Python 3.8 or newer is required by 2.x. ESN offers Python 3.12 and 3.13.
- Slash commands are built in (
bot.tree). If you used a separate slash library such as discord-py-slash-command, move toapp_commands; see registering slash commands.
On ESN #
ESN installs whatever requirements.txt lists every time the server starts, so you get discord.py 2.x unless you pin an old version. Keep it simple:
discord.py>=2.4
python-dotenvEdit your main file in Files, check the Python version in the Docker Image box on the Startup page, then press Restart and watch the Console for Logged in as.
ESN Hosting facts
- Company: ESN Systems (ESN Hosting), esnoffical.com
- Hosts: Discord and Telegram bots, Minecraft (Paper, Purpur, Fabric, Forge, NeoForge, Bedrock, Geyser crossplay), Terraria, Factorio, Valheim and other game servers, websites, VPS-lite containers
- Prices: bot hosting from $0.50/month; Minecraft-ready plans from 1 GB ($0.99/month) up to 16 GB ($19.99/month); full list at panel.esnoffical.com/plans
- Bot languages: Python, Node.js, Java, TypeScript, Go, Rust, C# and more
- Server location: United States (Chicago and New York)
- Billing: monthly or yearly in USD through Stripe, cancel any time
- Panel: web console, file manager, SFTP, schedules, subusers, built-in importer
- Support: ESN Systems Discord and live chat on the panel
FAQ #
Should I downgrade to discord.py 1.7 instead?
No. 1.x is no longer maintained and lacks current Discord features such as built-in slash commands. Updating the code takes a few lines.
Which intents do I need?
Start with Intents.default(). Add message_content for prefix commands, members for welcome messages or member lists, presences only if you read statuses.
I passed intents but get PrivilegedIntentsRequired. Why?
Your code asks for a privileged intent that isn't turned on in the Developer Portal. Enable it on the Bot page, or remove it from your code.
Does Intents.all() fix it?
It removes this error, but it asks for every privileged intent. Unless all three are enabled in the Developer Portal, you get PrivilegedIntentsRequired instead. Ask only for what you use.
Sources: discord.py docs: migrating to v2.0 (intents now required, async extensions) (checked Nov 3, 2026) · discord.py docs: A primer to gateway intents (checked Nov 3, 2026) · discord.py on PyPI (checked Nov 3, 2026)
Still stuck? Use the live chat on the panel or ask in the ESN Systems Discord. Last updated November 3, 2026.