(wards): Add moderator ward.
This commit is contained in:
@@ -11,7 +11,7 @@ from data import ORDER
|
|||||||
|
|
||||||
from utils.ui import Confirm, Pager
|
from utils.ui import Confirm, Pager
|
||||||
from utils.lib import error_embed, MessageArgs, utc_now
|
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 constants import MAX_COINS
|
||||||
|
|
||||||
from . import babel, logger
|
from . import babel, logger
|
||||||
@@ -113,7 +113,7 @@ class Economy(LionCog):
|
|||||||
"New balance to set the target's balance to."
|
"New balance to set the target's balance to."
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@low_management_ward
|
@moderator_ward
|
||||||
async def economy_balance_cmd(
|
async def economy_balance_cmd(
|
||||||
self,
|
self,
|
||||||
ctx: LionContext,
|
ctx: LionContext,
|
||||||
@@ -511,7 +511,7 @@ class Economy(LionCog):
|
|||||||
"Target user or role to view or update. Use @everyone to reset the entire guild."
|
"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(
|
async def economy_reset_cmd(
|
||||||
self,
|
self,
|
||||||
ctx: LionContext,
|
ctx: LionContext,
|
||||||
@@ -805,7 +805,7 @@ class Economy(LionCog):
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
@appcmds.default_permissions(manage_guild=True)
|
@appcmds.default_permissions(manage_guild=True)
|
||||||
@low_management_ward
|
@moderator_ward
|
||||||
async def configure_economy(self, ctx: LionContext,
|
async def configure_economy(self, ctx: LionContext,
|
||||||
allow_transfers: Optional[appcmds.Choice[int]] = None,
|
allow_transfers: Optional[appcmds.Choice[int]] = None,
|
||||||
coins_per_xp: Optional[appcmds.Range[int, 0, 2**15]] = None):
|
coins_per_xp: Optional[appcmds.Range[int, 0, 2**15]] = None):
|
||||||
|
|||||||
19
src/wards.py
19
src/wards.py
@@ -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 ----
|
# ---- Assorted manual wards and checks ----
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user