Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 模块';不和谐';没有属性';意图';错误_Python_Discord.py - Fatal编程技术网

Python 模块';不和谐';没有属性';意图';错误

Python 模块';不和谐';没有属性';意图';错误,python,discord.py,Python,Discord.py,我试图编写一个discord机器人程序,但当我运行该程序时,它会给出错误 回溯(最近一次呼叫最后一次): 文件“c:/Users/phara/Documents/GitHub/RayzeBot/bot.py”,第41行,在 intents=discord.intents.default() AttributeError:模块“discord”没有属性“Intents” import discord, asyncio, os, platform, sys from discord.ext.comm

我试图编写一个discord机器人程序,但当我运行该程序时,它会给出错误

回溯(最近一次呼叫最后一次): 文件“c:/Users/phara/Documents/GitHub/RayzeBot/bot.py”,第41行,在 intents=discord.intents.default() AttributeError:模块“discord”没有属性“Intents”

import discord, asyncio, os, platform, sys
from discord.ext.commands import Bot
from discord.ext import commands
import time
import random
if not os.path.isfile("config.py"):
    sys.exit("'config.py' not found! Please add it and try again.")
else:
    import config

""" 
Setup bot intents (events restrictions)
For more information about intents, please go to the following websites:
https://discordpy.readthedocs.io/en/latest/intents.html
https://discordpy.readthedocs.io/en/latest/intents.html#privileged-intents


Default Intents:
intents.messages = True
intents.reactions = True
intents.guilds = True
intents.emojis = True
intents.bans = True
intents.guild_typing = False
intents.typing = False
intents.dm_messages = False
intents.dm_reactions = False
intents.dm_typing = False
intents.guild_messages = True
intents.guild_reactions = True
intents.integrations = True
intents.invites = True
intents.voice_states = False
intents.webhooks = False

Privileged Intents (Needs to be enabled on dev page):
intents.presences = True
intents.members = True
"""

intents = discord.Intents.default()

我已经安装了最新版本的discord API,并且正在运行python 3.8。导致错误的原因是什么?如何修复它?

我刚刚运行了您的代码,它在我的电脑上运行。我正在使用python 3.6,但我认为这不应该是一个问题。可能尝试重新安装discord API?

似乎是discord版本的问题。在
discord.py 1.5.0中引入

导入不一致
打印(不一致的版本)
这在您的电脑中应该小于1.5

更新不和谐

pip install --upgrade discord.py
或者,如果要安装特定版本

pip install discord.py==1.5.0

您是否已启用此答案所示的特权意图?这回答了你的问题吗?我试过了,但它给了我同样的问题。我将尝试在早上重新启动电脑,这可能会有所帮助。重新启动电脑不会有帮助。您只需升级discord.py即可。感谢升级帮助,但vscode继续使用1.3.2,尽管我已经安装了1.6.0(我签入了cmd)。他们是解决这个问题的一种方法吗?刚刚解决了这个问题,必须使用python版本3.9而不是3.8。在vscode中使用来更改python版本