Get a Discord Role by Id

前端 未结 2 1725
不思量自难忘°
不思量自难忘° 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 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)
    

提交回复
热议问题