You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助: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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.13 11:15:32