python - 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”对象没有属性“提及”
解决方案
在新版本的 discord.py(1.5.x) 中,Intents
. 意图就像权限。您需要定义它以将消息发送到频道、成员等。
import discord
intents = discord.Intents().all()
client = discord.Bot(prefix='', intents=intents)
有关更多信息,您可以查看API 参考。
推荐阅读
- linux - 面临 rhel 6.4 上的绑定问题
- r - R中向量的元素级联
- django - 自 SSL/TLS 证书更新以来,Django 应用程序未连接到 RDS
- checkbox - 为什么我的验证码不显示?我不能点击复选框和按钮?
- sql - JSON输出的一个参数是空值
- java - 如何启动一个活动并将其显示在父活动中?
- vba - 访问中的 VBA。组合框的问题
- javascript - React - 按键事件首先在主体上触发,然后在元素上触发
- c# - 带有过滤器并等待它的 GetAll 上的 Task.FromResult - 不好的做法?
- swift - iOS 应用程序数据未传输到 Watch App