【问题标题】:How to use Bot top role position command in discord.py?如何在 discord.py 中使用 Bot top role position 命令?
【发布时间】:2021-05-09 17:14:19
【问题描述】:

嗨,我想在 ctx.author 角色位置低于 bot 角色时编写一个机器人,ctx.author 得到错误并且不能使用该命令,例如: 我编码了这个 (客户端是机器人对象)

@client.command()
async def ab(ctx):
    if client.top_role.position > ctx.author.top_role.position:
        await ctx.send('Error!')
        return
    staff
    .
    .
    .

但是机器人对象没有名为 top_role 的属性。 还有其他方法可以做这样的事情吗?有什么想法吗?

我也尝试使用 get_user(Id),但失败了。

【问题讨论】:

    标签: python python-3.x discord discord.py


    【解决方案1】:
    @client.command()
    async def ab(ctx):
        if ctx.guild.me.top_role >= ctx.author.top_role:
            await ctx.send('Error!')
            return
    

    【讨论】:

    • 工作!谢谢✨?
    猜你喜欢
    • 2019-08-22
    • 2020-08-16
    • 2019-07-23
    • 1970-01-01
    • 2018-08-10
    • 1970-01-01
    • 2021-01-02
    • 2020-09-12
    • 2021-07-09
    相关资源
    最近更新 更多