Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: make get_role more consistent #865

Merged
merged 15 commits into from Jun 18, 2022
15 changes: 10 additions & 5 deletions interactions/api/models/guild.py
Expand Up @@ -1638,14 +1638,19 @@ async def get_role(
:rtype: Role
"""

for role in self.roles:
if int(role.id) == role_id:
return role
if not self._client:
raise LibraryException(code=13)
roles = await self._client.get_all_roles(guild_id=int(self.id))
for i in roles:
if int(i["id"]) == role_id:
role = Role(**i)
break
return role
self.roles = [Role(**_) for _ in roles]
for role in self.roles:
if int(role.id) == role_id:
return role
raise LibraryException(
message="The role you looked for was not found!", code=0, severity=30
)

async def modify_role_position(
self,
Expand Down