fix: Missing permission wards.

This commit is contained in:
2023-08-18 12:56:44 +03:00
parent a0c56ebc13
commit 1b1371aef1
4 changed files with 34 additions and 8 deletions

View File

@@ -61,6 +61,9 @@ class GuildDashboard(BasePager):
# Map settingid -> setting of listening setting classes
self._listening = {}
async def interaction_check(self, interaction: discord.Interaction):
return self.access_check(interaction.user.id)
def access_check(self, userid):
return userid == self.callerid

View File

@@ -251,6 +251,7 @@ class MemberAdminCog(LionCog):
),
)
@high_management_ward
@appcmds.default_permissions(administrator=True)
async def cmd_resetmember(self, ctx: LionContext,
target: discord.User,
saved_roles: Optional[bool] = False,

View File

@@ -9,7 +9,7 @@ from discord.app_commands.transformers import AppCommandOptionType
from cachetools import LRUCache
from meta import LionBot, LionContext, LionCog
from wards import high_management_ward
from wards import high_management_ward, high_management_iward
from core.data import RankType
from utils.ui import ChoicedEnum, Transformed
from utils.lib import utc_now, replace_multiple
@@ -435,8 +435,6 @@ class RankCog(LionCog):
# ---------- Commands ----------
@cmds.hybrid_command(name=_p('cmd:ranks', "ranks"))
@appcmds.default_permissions(administrator=True)
@high_management_ward
async def ranks_cmd(self, ctx: LionContext):
"""
Command to access the Rank Overview UI.
@@ -450,8 +448,16 @@ class RankCog(LionCog):
if not ctx.interaction:
return
ui = RankOverviewUI(self.bot, ctx.guild, ctx.author.id)
await ui.run(ctx.interaction)
await ui.wait()
if await high_management_iward(ctx.interaction):
await ui.run(ctx.interaction)
await ui.wait()
else:
await ui.reload()
msg = await ui.make_message()
await ctx.reply(
**msg.send_args,
ephemeral=True
)
# ----- Guild Configuration -----
@LionCog.placeholder_group

View File

@@ -69,9 +69,25 @@ class MenuStyleParam(ChoicedEnum):
)
@appcmds.guild_only
async def rolemenu_ctxcmd(interaction: discord.Interaction, message: discord.Message):
# TODO: Permission wards!
bot = interaction.client
self = bot.get_cog('RoleMenuCog')
bot: LionBot = interaction.client
self: RoleMenuCog = bot.get_cog('RoleMenuCog')
t = bot.translator.t
# Ward for manage_roles
if not interaction.user.guild_permissions.manage_roles:
raise UserInputError(
t(_p(
'ctxcmd:rolemenu|error:author_perms',
"You need the `MANAGE_ROLES` permission in order to manage the server role menus."
))
)
if not interaction.guild.me.guild_permissions.manage_roles:
raise UserInputError(
t(_p(
'ctxcmd:rolemenus|error:my_perms',
"I lack the `MANAGE_ROLES` permission required to offer roles from role menus."
))
)
await interaction.response.defer(thinking=True, ephemeral=True)
# Lookup the rolemenu in the active message cache