首页 > 解决方案 > discord.ext.commands.errors.CommandInvokeError:命令引发异常:AttributeError:“NoneType”对象没有属性“提及”

问题描述

我的代码:


@commands.command(pass_context=True)
@commands.guild_only()
async def owner_mention(self, ctx):
    await ctx.send(ctx.guild.owner.mention)

错误:

discord.ext.commands.errors.CommandInvokeError:命令引发异常:AttributeError:“NoneType”对象没有属性“提及”

标签: pythondiscorddiscord.py

解决方案


在新版本的 discord.py(1.5.x) 中,Intents. 意图就像权限。您需要定义它以将消息发送到频道、成员等。

import discord

intents = discord.Intents().all()
client = discord.Bot(prefix='', intents=intents)

有关更多信息,您可以查看API 参考


推荐阅读