From c7a60e91275759d676c4b47b5f7359981c6de80e Mon Sep 17 00:00:00 2001 From: Jacob Coffee Date: Fri, 8 Mar 2024 22:35:32 -0600 Subject: [PATCH] feat: add predicate for guild admin check --- src/byte/lib/utils.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/byte/lib/utils.py b/src/byte/lib/utils.py index 777664e..4f18d76 100644 --- a/src/byte/lib/utils.py +++ b/src/byte/lib/utils.py @@ -29,6 +29,10 @@ "RuffRule", "FormattedRuffRule", "PEP", + "PEPType", + "PEPStatus", + "PEPHistoryItem", + "is_guild_admin", "is_byte_dev", "linker", "mention_user", @@ -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.