I was trying to make a quick bot for discord and I used this code:
import discord from discord.ui import button, view from discord.ext import commands client = discord.Client() @client.event async def on_ready(): print('Autenticazione riuscita. {0.user} è online!'.format(client)) But this error pops up:
Client.__init__() missing 1 required keyword-only argument: 'intents' I tried providing an argument by putting something between the brackets, like this:
import discord from discord.ui import button, view from discord.ext import commands client = discord.Client(0) @client.event async def on_ready(): print('Autenticazione riuscita. {0.user} è online!'.format(client)) But instead I get this error:
Client.__init__() takes 1 positional argument but 2 were given On another PC the exact same code, with exact same modules and same Python version works just fine. What am I missing?
24 Answers
You could use the default Intents unless you have a particular one to specify.
client = discord.Client(intents=discord.Intents.default()) As the first error message says, it is a keyword-only argument, so you cannot write discord.Client(discord.Intents.default()) without intents=.
See Intents for more details.
With older versions, you can't get the messages.
Try using this
intents = discord.Intents.default() intents.message_content = True client = discord.Client(intents=intents) My suggestion here would be to uninstall the version of discord.py you currently have and install version 1.7.3.
I was having the same issue and realized that a new version of the module had been released recently. Once I reverted back to an older version, everything worked by just using
client = discord.Client() i had the same issue, its a version issue use: pip install -U discord==1.7.3 pip install -U discord.py==1.7.3
this should fix it, at least for me it did
1