求助:TypeError报错,intents参数应为Intents而非discord.flags.Intents
问题原因
你错误混用了discord库的Intents类与disnake库的commands.Bot。disnake作为discord.py的分支,拥有独立的Intents实现,无法直接兼容原生discord库的对应类,这才触发了类型不匹配的错误。
解决方法
修改代码,改用disnake自带的Intents类:
from disnake.ext import commands import disnake intents = disnake.Intents.all() bot = commands.Bot( command_prefix=".", intents=intents, test_guilds=[1040948288054112316], ) @bot.slash_command(name="test", description="test") async def test(inter): await inter.response.send_message("test")
补充说明
- 确保项目仅安装
disnake库,若同时存在discord.py可能引发混淆,建议清理多余依赖。 - disnake的API设计虽与discord.py高度相似,但所有组件都需从
disnake或disnake.ext导入,禁止混用原生discord库的类。
内容的提问来源于stack exchange,提问作者skrvt
相关产品推荐
相关产品推荐

