【发布时间】:2021-06-29 19:24:43
【问题描述】:
我正在尝试编写一个不和谐的机器人,但是当我运行程序时它给出了错误
Traceback(最近一次调用最后一次): 文件“c:/Users/phara/Documents/GitHub/RayzeBot/bot.py”,第 41 行,在 意图 = 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 导致错误的原因是什么,我该如何解决?
【问题讨论】:
-
您是否按照此答案的建议启用了特权意图? stackoverflow.com/questions/64831017/…
-
这能回答你的问题吗? How do I get the discord.py intents to work?
标签: python discord.py