简体   繁体   English

Discord bot 正在运行,但在使用 VS Code 后没有响应命令

[英]Discord bot is running but not responding to commands after using VS Code

So I was first running my code on replit.com and I decided to switch over to running it localy on my computer.所以我首先在 replit.com 上运行我的代码,然后我决定切换到在我的计算机上本地运行它。 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:我让它在 Python IDLE 3.10.1 上运行,然后我决定用相同的解释器在 VS Code 上运行它,然后我得到了一个错误:

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.这行代码在 repli 和 IDLE 上都有效,在 VS 代码上运行后它也停止在 IDLE 上运行。 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; 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.在 replit 上运行 discord bot,切换到 Python IDLE 3.10.1 继续工作,切换到 VS Code 出现错误,修复错误,bot 在 IDLE 和 VS Code 上不再工作。

Try this :)尝试这个 :)

from discord.ext import commands

botDescription="Bot"
intents = discord.Intents.all()
client = commands.Bot(command_prefix="?", help_command=None, description=botDescription, intents=intents)

The Bot it self need the right to handle intents. Bot 它自己需要处理意图的权利。 Go to discord.com/developers/applications > Bot > SERVER MEMBERS INTENT > True转到 discord.com/developers/applications > Bot > SERVER MEMBERS INTENT > True

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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