refactor(bot): ♻️ Change custom is_owner() for @commands.is_owner().
This commit is contained in:
+3
-3
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user