Changing role hierarchy with discord.py

…衆ロ難τιáo~ 提交于 2020-07-21 11:26:34

问题


I want to create a new role in discord.py.

But I want this role to be in the (let's say) 3rd spot of the roles. How can I achieve this?


回答1:


You would use Role.edit, passing a position value, which must be lower than the position of your highest role.

@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")



回答2:


discord.Client.move_role() seems to be what you're after



来源:https://stackoverflow.com/questions/58975932/changing-role-hierarchy-with-discord-py

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!