Skip to content

Commit ced71df

Browse files
debowkiiLordOfPollssilasarypre-commit-ci[bot]
authored
feat: add Member.has_any_role (#1620)
* add has_any_role * Add missing stub * ci: correct from checks. --------- Co-authored-by: LordOfPolls <dev@lordofpolls.com> Co-authored-by: Katelyn Gigante <clockwork.singularity@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent af9866f commit ced71df

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

interactions/models/discord/user.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,16 @@ def has_role(self, *roles: Union[Snowflake_Type, Role]) -> bool:
604604
"""
605605
return all(to_snowflake(role) in self._role_ids for role in roles)
606606

607+
def has_any_role(self, roles: List[Union[Snowflake_Type, Role]]) -> bool:
608+
"""
609+
Checks if the user has any of the given roles.
610+
611+
Args:
612+
*roles: The Role(s) or role id(s) to check for
613+
614+
"""
615+
return any((self.has_role(to_snowflake(role)) for role in roles))
616+
607617
async def timeout(
608618
self,
609619
communication_disabled_until: Union["Timestamp", datetime, int, float, str, None],

interactions/models/discord/user.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ class Member(FakeUserMixin):
152152
async def remove_role(self, role: Union[Snowflake_Type, Role], reason: Absent[str] = ...) -> None: ...
153153
async def remove_roles(self, roles: Iterable[Union[Snowflake_Type, Role]], reason: Absent[str] = ...) -> None: ...
154154
def has_role(self, *roles: Union[Snowflake_Type, Role]) -> bool: ...
155+
def has_any_role(self, roles: List[Union[Snowflake_Type, Role]]) -> bool: ...
155156
async def timeout(
156157
self,
157158
communication_disabled_until: Union["Timestamp", datetime, int, float, str, None],

0 commit comments

Comments
 (0)