【问题标题】:discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'mention'discord.ext.commands.errors.CommandInvokeError:命令引发异常:AttributeError:'NoneType'对象没有属性'提及'
【发布时间】:2021-02-05 10:17:16
【问题描述】:

我的代码:


@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”对象没有属性 '提及'

【问题讨论】:

  • ctx.guild.owner 是 None 所以你不能得到 mention 属性

标签: python discord discord.py


【解决方案1】:

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

import discord

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

更多信息,您可以查看API References

【讨论】:

    猜你喜欢
    • 2022-01-25
    • 1970-01-01
    • 2021-01-30
    • 2021-12-07
    • 1970-01-01
    • 2022-01-05
    • 1970-01-01
    • 2019-02-24
    • 1970-01-01
    相关资源
    最近更新 更多