From 93026b83257b77202054f7e05d3c144153df70c9 Mon Sep 17 00:00:00 2001 From: "Nyeki.py" <84998222+Nekidev@users.noreply.github.com> Date: Mon, 21 Oct 2024 13:32:08 -0300 Subject: [PATCH] refactor(bot): :recycle: Change custom `is_owner()` for `@commands.is_owner()`. --- payphone/bot.py | 6 +++--- payphone/cogs/mods/cog.py | 11 +++-------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/payphone/bot.py b/payphone/bot.py index f5115a2..1e21183 100644 --- a/payphone/bot.py +++ b/payphone/bot.py @@ -14,7 +14,6 @@ from payphone.core import constants, exceptions, formatting, help_command, confi from payphone.core.redis import redis -# TODO: Make it an AutoShardedBot on production. class Payphone(commands.AutoShardedBot): def __init__(self) -> None: intents = discord.Intents.default() @@ -30,6 +29,7 @@ class Payphone(commands.AutoShardedBot): help_command=help_command.HelpCommand(), strip_after_prefix=True, case_insensitive=True, + owner_ids=[898569996949676052, 777338793803513886], ) async def on_ready(self) -> None: @@ -146,7 +146,7 @@ class Payphone(commands.AutoShardedBot): duration: timedelta | None, reason: str, moderator: discord.User | discord.Member | models.User | int | None = None, - report_id: int | None = None + report_id: int | None = None, ) -> models.Ban: """Bans a user from Payphone. @@ -200,7 +200,7 @@ class Payphone(commands.AutoShardedBot): reason=reason, expires_at=until, banned_by_id=mod_id, - report_id=report_id + report_id=report_id, ) await redis.set(key, "1", ex=300) diff --git a/payphone/cogs/mods/cog.py b/payphone/cogs/mods/cog.py index 2c4a0c5..6227684 100644 --- a/payphone/cogs/mods/cog.py +++ b/payphone/cogs/mods/cog.py @@ -18,11 +18,6 @@ from payphone.cogs.mods import embeds, views from payphone.core import checks, converters, constants, formatting as fmt from payphone.core.redis import redis -OWNER_IDS = {898569996949676052, 777338793803513886} -def is_owner(): - async def predicate(ctx: commands.Context) -> bool: - return ctx.author.id in OWNER_IDS - return commands.check(predicate) class Mods(base.Cog): show_in_help = False @@ -203,7 +198,7 @@ class Mods(base.Cog): ) @commands.command(aliases=["mod"]) - @is_owner() + @commands.is_owner() @transactions.atomic() async def moderator( self, @@ -234,7 +229,7 @@ class Mods(base.Cog): ) @commands.command(aliases=["restart"]) - @is_owner() + @commands.is_owner() @transactions.atomic() async def shutdown( self, ctx: commands.Context, seconds: int = 60, *, reason: str | None @@ -311,7 +306,7 @@ class Mods(base.Cog): sys.exit() @commands.command() - @is_owner() + @commands.is_owner() async def stats( self, ctx: commands.Context, iterations: int = 5, wait: int = 5 ) -> None: