Getting an error when setting up my Discord bot. What's wrong?

Hey everyone! I’m trying to create a Discord bot but I’m running into an issue when I try to run it. Here’s the error I’m getting:

TypeError: intents parameter must be Intent not <class 'int'>

I think it might be related to how I’m setting up the intents, but I’m not entirely sure. Here’s a simplified version of my code:

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix='>', intents=42)

@bot.event
async def on_ready():
    print('Bot is online!')

@bot.command()
async def hello(ctx):
    await ctx.send('Hello there!')

bot.run('MY_TOKEN')

Can anyone help me figure out what I’m doing wrong? I’m pretty new to Discord bot development, so any advice would be appreciated!

yo, had the same prob. its the intents thing. instead of puttin a number, u gotta use discord.Intents.default(). like this:

bot = commands.Bot(command_prefix=‘>’, intents=discord.Intents.default())

that should fix it. lmk if u need more help

The issue lies in how you’re setting up the intents. Instead of passing an integer (42), you need to create an Intents object. Try modifying your code like this:

intents = discord.Intents.default()
bot = commands.Bot(command_prefix='>', intents=intents)

This creates a default Intents object and passes it to the Bot constructor. If you need specific intents, you can enable them individually:

intents.message_content = True
intents.guilds = True

Remember to import the Intents class at the top of your file:

from discord import Intents

This should resolve the TypeError you’re encountering. Let me know if you need any further clarification!

I encountered a similar issue in my own projects. The root of the problem is using an integer for the intents parameter, which should instead be an instance of the Intents class. In my case, I fixed it by importing Intents from discord and creating an instance with Intents.default(), then passing that instance to the Bot constructor. This approach ensures the bot has the correct setup and avoids the TypeError. If you need additional intents, enable them on the Intents object before using it. This solution worked well for me and should help you as well.