【问题标题】:errors while trying to use users.nitro discord.py尝试使用 users.nitro discord.py 时出错
【发布时间】:2021-01-11 21:08:00
【问题描述】:
    @client.command()
    async def nitro(ctx):
        nitro = ctx.message.author.discord.profile.nitro
        embed = discord.Embed(title=f":house_with_garden: {ctx.message.author} - Stats",
                              description=f"Nitro: {nitro}",
                              color=discord.Colour.green())
        await ctx.send(embed=embed)

每当我运行此程序时,我都会收到此错误:

"discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Member' object has no attribute 'discord'" 

我想在我输入时说明用户是否有硝基:.nitro @username

【问题讨论】:

    标签: python discord.py


    【解决方案1】:

    使用ctx.message.author.profile().nitro,因为discord.Profile 是一个代表用户个人资料的类(可通过Member.profile 访问)。

    【讨论】:

    • 我现在得到这个错误:discord.ext.commands.errors.CommandInvokeError:命令引发异常:AttributeError:'function'对象没有属性'nitro'
    • @Frenology 实际上,您似乎无法做到这一点。我检查了文档,它说只有非机器人帐户才能访问配置文件。
    • 能否获得用户徽章,例如:hypesquad 等?
    • 是的,使用ctx.message.author.public_flags。这个属性有什么我不太了解,看the docs
    猜你喜欢
    • 1970-01-01
    • 2022-11-16
    • 1970-01-01
    • 1970-01-01
    • 2022-01-05
    • 2021-01-29
    • 1970-01-01
    • 2017-07-18
    • 2017-02-08
    相关资源
    最近更新 更多