Skip to content

Commit d4b7e09

Browse files
EepyElvyrai0bsFayeDelpre-commit-ci[bot]
authored
refactor: make get_role more consistent (#865)
* ADMIN/revert: remove unwanted file. This file was actually cloned outside of the client directory in a PR that had not appropriately adjusted to the new architectural layout of the library. * chore: Update requirements.txt * chore: Version bump. * chore/ADMIN: force version onto old pypi This is an executive decision made between Delta and I. We will be forcing a version 4.0 push onto our old branch to help transition old users using v3 to our new project. This does not necessarily mean this branch will now be receiving updates along with the rest. The goal is to make our current branch used as much as possible. * chore/ADMIN: fix content type * fix/ADMIN: correct improper description * revert/ADMIN: change back to original * Update guild.py * ci: correct from checks. Co-authored-by: fl0w <41456914+goverfl0w@users.noreply.github.com> Co-authored-by: DeltaX <33706469+DeltaXWizard@users.noreply.github.com> Co-authored-by: Sofia <41456914+ffl0w@users.noreply.github.com> Co-authored-by: James Walston <41456914+jameswalston@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent a756199 commit d4b7e09

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

interactions/api/models/guild.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,14 +1645,19 @@ async def get_role(
16451645
:rtype: Role
16461646
"""
16471647

1648+
for role in self.roles:
1649+
if int(role.id) == role_id:
1650+
return role
16481651
if not self._client:
16491652
raise LibraryException(code=13)
16501653
roles = await self._client.get_all_roles(guild_id=int(self.id))
1651-
for i in roles:
1652-
if int(i["id"]) == role_id:
1653-
role = Role(**i)
1654-
break
1655-
return role
1654+
self.roles = [Role(**_) for _ in roles]
1655+
for role in self.roles:
1656+
if int(role.id) == role_id:
1657+
return role
1658+
raise LibraryException(
1659+
message="The role you looked for was not found!", code=0, severity=30
1660+
)
16561661

16571662
async def modify_role_position(
16581663
self,

0 commit comments

Comments
 (0)