简体   繁体   中英

Discord Client error when running discord bot with python

So I was first running my code on replit.com and I decided to switch over to running it localy on my computer. I got it running on Python IDLE 3.10.1 and then I decided to run it on VS Code with the same interpreter and then I got an error:

TypeError: Client.__init__() missing 1 required keyword-only argument: 'intents'

On this line of code:

client = discord.Client()

And this line of code was working both on replit and on IDLE and after running it on VS code it stopped running on IDLE aswell. And after I fixed the error with this I found on stack overflow:

client = discord.Client(intents=discord.Intents.default())

The bot seems to be running in the console, but in reality it isn't running because it isn't responding to my commands.

I also get these weird messages before the bot "starts":

TLDR; Running discord bot on replit, switched to Python IDLE 3.10.1 kept working, switched to VS Code error appeared, fixed error, bot not working anymore on IDLE and VS Code.

I fixed it like this:

Code:

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

client = discord.Client(intents=intents)

And from the discord dev portal you need to enable whatever priviledges you want, in my case message priviledges

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM