I am trying to get a list of all the roles my bot has from top to bottom so I can get the highest role’s color.
Advertisement
Answer
Not sure what you mean by the “highest role’s color”, also your post is missing your code.
One way to get the roles the bot has in the guild (via a command) is to get the guild member object and then loop the role objects for that member.
Try this:
@bot.command() async def list_roles(ctx): bot_member = ctx.guild.get_member(bot.user.id) for bot_role in bot_member.roles: print(f'guild role {bot_role} color {bot_role.color}')
Console output:
guild role @everyone color #000000 guild role masterbot color #2ecc71 guild role winnerPicker color #e67e22 guild role gabAdmin color #ad1457