Get a Discord Role by Id

前端 未结 2 1705
不思量自难忘°
不思量自难忘° 2021-01-20 01:46

I\'m making a Discord bot but just ran into a problem.

I want to modify a role. A specific role. I know how to do that with edit_role, but I need to get

相关标签:
2条回答
  • 2021-01-20 01:59

    You can simply use Guild.get_role(role_id) to get the role if you have the id.

    role_id = 2134532534
    role = my_server.get_role(role_id)
    
    0 讨论(0)
  • 2021-01-20 02:18

    You can use discord.utils.get to loop through Guild.roles and get the one you're looking for:

    from discord.utils import get
    
    role_id = 123
    role = get(guild.roles, id=role_id)
    
    0 讨论(0)
提交回复
热议问题