Skip to content

Commit

Permalink
feat: add predicate for guild admin check
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobCoffee committed Mar 9, 2024
1 parent 2ff7c4a commit c7a60e9
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/byte/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
"RuffRule",
"FormattedRuffRule",
"PEP",
"PEPType",
"PEPStatus",
"PEPHistoryItem",
"is_guild_admin",
"is_byte_dev",
"linker",
"mention_user",
Expand Down Expand Up @@ -142,6 +146,27 @@ class PEP(TypedDict):
url: str


def is_guild_admin() -> Check[Any]:
"""Check if the user is a guild admin.
Returns:
A check function.
"""

async def predicate(ctx: Context) -> bool:
"""Check if the user is a guild admin.
Args:
ctx: Context object.
Returns:
True if the user is a guild admin, False otherwise.
"""
return ctx.author.guild_permissions.administrator

return commands.check(predicate)


def is_byte_dev() -> Check[Any]:
"""Check if the user is a Byte developer.
Expand Down

0 comments on commit c7a60e9

Please sign in to comment.