(wards): Add moderator ward.

This commit is contained in:
2023-08-22 22:48:22 +03:00
parent 8d19cf5d2d
commit 4ddece1e0f
2 changed files with 23 additions and 4 deletions

View File

@@ -11,7 +11,7 @@ from data import ORDER
from utils.ui import Confirm, Pager
from utils.lib import error_embed, MessageArgs, utc_now
from wards import low_management_ward
from wards import low_management_ward, moderator_ward
from constants import MAX_COINS
from . import babel, logger
@@ -113,7 +113,7 @@ class Economy(LionCog):
"New balance to set the target's balance to."
)
)
@low_management_ward
@moderator_ward
async def economy_balance_cmd(
self,
ctx: LionContext,
@@ -511,7 +511,7 @@ class Economy(LionCog):
"Target user or role to view or update. Use @everyone to reset the entire guild."
),
)
@low_management_ward
@moderator_ward
async def economy_reset_cmd(
self,
ctx: LionContext,
@@ -805,7 +805,7 @@ class Economy(LionCog):
]
)
@appcmds.default_permissions(manage_guild=True)
@low_management_ward
@moderator_ward
async def configure_economy(self, ctx: LionContext,
allow_transfers: Optional[appcmds.Choice[int]] = None,
coins_per_xp: Optional[appcmds.Range[int, 0, 2**15]] = None):

View File

@@ -99,6 +99,25 @@ async def low_management_ward(ctx: LionContext) -> bool:
)
@cmds.check
async def moderator_ward(ctx: LionContext) -> bool:
if not ctx.guild:
return False
passed = await low_management(ctx.bot, ctx.author)
if passed:
return True
modrole = ctx.lguild.data.mod_role
roleids = [role.id for role in ctx.author.roles]
if not (modrole and modrole in roleids):
raise CheckFailure(
ctx.bot.translator.t(_p(
'ward:moderator|failed',
"You must have the configured moderator role, "
"or `MANAGE_GUILD` permissions to do this."
))
)
return True
# ---- Assorted manual wards and checks ----