python - 使用 discord.py 更改角色层次结构

标签 python discord discord.py

我想在 discord.py 中创建一个新角色。

但我希望这个角色位于(比方说)角色的第三位。 我怎样才能做到这一点?

最佳答案

您将使用 Role.edit ,传递一个 position 值,该值必须低于您最高角色的位置。

@bot.command()
async def moverole(ctx, role: discord.Role, pos: int):
    try:
        await role.edit(position=pos)
        await ctx.send("Role moved.")
    except discord.Forbidden:
        await ctx.send("You do not have permission to do that")
    except discord.HTTPException:
        await ctx.send("Failed to move role")
    except discord.InvalidArgument:
        await ctx.send("Invalid argument")

关于python - 使用 discord.py 更改角色层次结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58975932/

相关文章:

python - Keras 回归的模型建议

python - azureml 可以将变量从一个步骤传递到另一步骤吗?

javascript - 根据使用的邀请码为新成员分配角色

javascript - 通过 JS 脚本和 Google Sheets API 抓取图表作为图像?

python - 使用不同的参数多次运行 python 脚本

python - Anaconda,更新Pytorch到最新版本1.5

node.js - 使用 VoiceReceiver Discord 保存用户语音

python - 如何确保用户在discord.py 中输入完整命令?

python - 使用 Python 编写 Discord 机器人程序——如何让它加入语音 channel ?

python - 访问嵌套值