问题
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