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
|
from payphone.core.redis import redis
|
||||||
|
|
||||||
|
|
||||||
# TODO: Make it an AutoShardedBot on production.
|
|
||||||
class Payphone(commands.AutoShardedBot):
|
class Payphone(commands.AutoShardedBot):
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
intents = discord.Intents.default()
|
intents = discord.Intents.default()
|
||||||
@@ -30,6 +29,7 @@ class Payphone(commands.AutoShardedBot):
|
|||||||
help_command=help_command.HelpCommand(),
|
help_command=help_command.HelpCommand(),
|
||||||
strip_after_prefix=True,
|
strip_after_prefix=True,
|
||||||
case_insensitive=True,
|
case_insensitive=True,
|
||||||
|
owner_ids=[898569996949676052, 777338793803513886],
|
||||||
)
|
)
|
||||||
|
|
||||||
async def on_ready(self) -> None:
|
async def on_ready(self) -> None:
|
||||||
@@ -146,7 +146,7 @@ class Payphone(commands.AutoShardedBot):
|
|||||||
duration: timedelta | None,
|
duration: timedelta | None,
|
||||||
reason: str,
|
reason: str,
|
||||||
moderator: discord.User | discord.Member | models.User | int | None = None,
|
moderator: discord.User | discord.Member | models.User | int | None = None,
|
||||||
report_id: int | None = None
|
report_id: int | None = None,
|
||||||
) -> models.Ban:
|
) -> models.Ban:
|
||||||
"""Bans a user from Payphone.
|
"""Bans a user from Payphone.
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ class Payphone(commands.AutoShardedBot):
|
|||||||
reason=reason,
|
reason=reason,
|
||||||
expires_at=until,
|
expires_at=until,
|
||||||
banned_by_id=mod_id,
|
banned_by_id=mod_id,
|
||||||
report_id=report_id
|
report_id=report_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
await redis.set(key, "1", ex=300)
|
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 import checks, converters, constants, formatting as fmt
|
||||||
from payphone.core.redis import redis
|
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):
|
class Mods(base.Cog):
|
||||||
show_in_help = False
|
show_in_help = False
|
||||||
@@ -203,7 +198,7 @@ class Mods(base.Cog):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@commands.command(aliases=["mod"])
|
@commands.command(aliases=["mod"])
|
||||||
@is_owner()
|
@commands.is_owner()
|
||||||
@transactions.atomic()
|
@transactions.atomic()
|
||||||
async def moderator(
|
async def moderator(
|
||||||
self,
|
self,
|
||||||
@@ -234,7 +229,7 @@ class Mods(base.Cog):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@commands.command(aliases=["restart"])
|
@commands.command(aliases=["restart"])
|
||||||
@is_owner()
|
@commands.is_owner()
|
||||||
@transactions.atomic()
|
@transactions.atomic()
|
||||||
async def shutdown(
|
async def shutdown(
|
||||||
self, ctx: commands.Context, seconds: int = 60, *, reason: str | None
|
self, ctx: commands.Context, seconds: int = 60, *, reason: str | None
|
||||||
@@ -311,7 +306,7 @@ class Mods(base.Cog):
|
|||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@is_owner()
|
@commands.is_owner()
|
||||||
async def stats(
|
async def stats(
|
||||||
self, ctx: commands.Context, iterations: int = 5, wait: int = 5
|
self, ctx: commands.Context, iterations: int = 5, wait: int = 5
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user