我对此很陌生。我试图为我和我的朋友创建一个 Discord 机器人,但我收到了这个错误(标题)。我不知道如何解决它。我升级了discord.py并设置了“intents.messages = True”。如果我使用“intents = discord.Intents.all()”,我会收到错误(这就是我使用“intents = discord.Intents.default()”的原因),我只想知道我必须做什么。在这一点上,这是个人的。 是的,我看到另一篇文章有同样的错误,但该解决方案对我不起作用 我使用Python 3.9.12
`import os
import discord
from discord.ext import commands
from discord.ext import tasks
from discord.ext.commands import has_permissions, MissingPermissions
from discord.utils import get
from dotenv import load_dotenv
import urllib.request
import json
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
intents = discord.Intents(messages=True, guilds=True)
#intents = discord.Intents.default()
intents.messages = True
bot = commands.Bot(command_prefix = "!", intents=intents)
bot.remove_command('help')
@bot.event
async def on_ready():
print(f'Conectado como {bot.user.name}')`
还有另一个适用于消息的意图:
intents.message_content = True
这使得机器人能够处理消息的内容,而不仅仅是消息本身。