Added myself as "owner" using @is_owner(), and fixed an issue with sadd where it now handle cases where the list of call_ids is empty.
This commit is contained in:
@@ -18,6 +18,11 @@ 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
|
||||
@@ -198,7 +203,7 @@ class Mods(base.Cog):
|
||||
)
|
||||
|
||||
@commands.command(aliases=["mod"])
|
||||
@commands.is_owner()
|
||||
@is_owner()
|
||||
@transactions.atomic()
|
||||
async def moderator(
|
||||
self,
|
||||
@@ -229,7 +234,7 @@ class Mods(base.Cog):
|
||||
)
|
||||
|
||||
@commands.command(aliases=["restart"])
|
||||
@commands.is_owner()
|
||||
@is_owner()
|
||||
@transactions.atomic()
|
||||
async def shutdown(
|
||||
self, ctx: commands.Context, seconds: int = 60, *, reason: str | None
|
||||
@@ -295,7 +300,9 @@ class Mods(base.Cog):
|
||||
|
||||
calls = await models.Call.filter(ended_at=None)
|
||||
|
||||
await redis.sadd(constants.CALL_IDS_TO_FLUSH, *(call.id for call in calls))
|
||||
call_ids = [call.id for call in calls]
|
||||
if call_ids:
|
||||
await redis.sadd(constants.CALL_IDS_TO_FLUSH, *call_ids)
|
||||
|
||||
await self.bot.get_cog("Calls").flush_messages()
|
||||
|
||||
@@ -304,7 +311,7 @@ class Mods(base.Cog):
|
||||
sys.exit()
|
||||
|
||||
@commands.command()
|
||||
@commands.is_owner()
|
||||
@is_owner()
|
||||
async def stats(
|
||||
self, ctx: commands.Context, iterations: int = 5, wait: int = 5
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user