繁体   English   中英

Discord.py:NameError:未定义名称“意图”

[英]Discord.py: NameError: name 'intents' is not defined

我正在尝试在我的机器人中使用意图,但在运行以下代码时:

import discord
from discord.ext import commands

intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix=prefix, intent=intents)

我收到错误:

  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discor
Traceback (most recent call last):
  File "main.py", line 3, in <module>
    intents = discord.Intents.default()
AttributeError: module 'discord' has no attribute 'Intents'

我正在运行 Python 3.8.2,但我不知道为什么会这样。 任何帮助都会得到认可(:

您很可能实际上并未使用 discord.py 1.5.1,您可以在导入后打印discord.__version__以进行仔细检查。 最佳实践是将 Python venv用于此类包。 此外,为了确保您始终访问正确的 pip,您可以使用python -m pip 这意味着您始终将 pip 用于稍后将使用的相同版本。

暂无
暂无

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

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