How to Get the Discord.Py Intents to Work

How do I get the discord.py intents to work?

intents = discord.Intents.default()
intents.members = True

client = commands.Bot(command_prefix=',', intents=intents)

You also have to enable privileged intents in the developer portal

A Primer Gateway to Intents

Enable intents for discord.py bot

intents were introduced in 1.5.0 so I don't think they were working before, but answering your question

intents = discord.Intents.default()
intents.members = True

bot = commands.Bot(..., intents=intents)

Also remember to enable privileged member intents in the developer portal

How to enable privigeled intents

Python discord bot doesn't answer to any commands

To improve privacy bots now need a special intent in order to be able to read messages. The "new" commands (which i would recommend you to switch to) are slash commands as they are fully supported by Discord. You can find more information on how to set up slash commands here.

If you want to stick with the old method, here is he to activate the intent: First go to your Developer Portal, select your application and activate the Message Content Intent. Next you need to activate the intent in your code like this:

intents = discord.Intents.default()
intents.messages = True
bot = commands.Bot(command_prefix='!', help_command=None, case_insensitive=True, intents=intents)

Note that if your bot is on 100 or more servers it needs to be verified in order to access intents. More information on that can be found here.

Discord.py Priveleged Intents stopping on_message and commands from working

I'm guessing that using intents = discord.Intents() has all intents set to False.

You can either use intents.messages = True or intents.all().



Related Topics



Leave a reply



Submit