fix: Missing permission wards.
This commit is contained in:
@@ -61,6 +61,9 @@ class GuildDashboard(BasePager):
|
|||||||
# Map settingid -> setting of listening setting classes
|
# Map settingid -> setting of listening setting classes
|
||||||
self._listening = {}
|
self._listening = {}
|
||||||
|
|
||||||
|
async def interaction_check(self, interaction: discord.Interaction):
|
||||||
|
return self.access_check(interaction.user.id)
|
||||||
|
|
||||||
def access_check(self, userid):
|
def access_check(self, userid):
|
||||||
return userid == self.callerid
|
return userid == self.callerid
|
||||||
|
|
||||||
|
|||||||
@@ -251,6 +251,7 @@ class MemberAdminCog(LionCog):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
@high_management_ward
|
@high_management_ward
|
||||||
|
@appcmds.default_permissions(administrator=True)
|
||||||
async def cmd_resetmember(self, ctx: LionContext,
|
async def cmd_resetmember(self, ctx: LionContext,
|
||||||
target: discord.User,
|
target: discord.User,
|
||||||
saved_roles: Optional[bool] = False,
|
saved_roles: Optional[bool] = False,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from discord.app_commands.transformers import AppCommandOptionType
|
|||||||
from cachetools import LRUCache
|
from cachetools import LRUCache
|
||||||
|
|
||||||
from meta import LionBot, LionContext, LionCog
|
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 core.data import RankType
|
||||||
from utils.ui import ChoicedEnum, Transformed
|
from utils.ui import ChoicedEnum, Transformed
|
||||||
from utils.lib import utc_now, replace_multiple
|
from utils.lib import utc_now, replace_multiple
|
||||||
@@ -435,8 +435,6 @@ class RankCog(LionCog):
|
|||||||
|
|
||||||
# ---------- Commands ----------
|
# ---------- Commands ----------
|
||||||
@cmds.hybrid_command(name=_p('cmd:ranks', "ranks"))
|
@cmds.hybrid_command(name=_p('cmd:ranks', "ranks"))
|
||||||
@appcmds.default_permissions(administrator=True)
|
|
||||||
@high_management_ward
|
|
||||||
async def ranks_cmd(self, ctx: LionContext):
|
async def ranks_cmd(self, ctx: LionContext):
|
||||||
"""
|
"""
|
||||||
Command to access the Rank Overview UI.
|
Command to access the Rank Overview UI.
|
||||||
@@ -450,8 +448,16 @@ class RankCog(LionCog):
|
|||||||
if not ctx.interaction:
|
if not ctx.interaction:
|
||||||
return
|
return
|
||||||
ui = RankOverviewUI(self.bot, ctx.guild, ctx.author.id)
|
ui = RankOverviewUI(self.bot, ctx.guild, ctx.author.id)
|
||||||
|
if await high_management_iward(ctx.interaction):
|
||||||
await ui.run(ctx.interaction)
|
await ui.run(ctx.interaction)
|
||||||
await ui.wait()
|
await ui.wait()
|
||||||
|
else:
|
||||||
|
await ui.reload()
|
||||||
|
msg = await ui.make_message()
|
||||||
|
await ctx.reply(
|
||||||
|
**msg.send_args,
|
||||||
|
ephemeral=True
|
||||||
|
)
|
||||||
|
|
||||||
# ----- Guild Configuration -----
|
# ----- Guild Configuration -----
|
||||||
@LionCog.placeholder_group
|
@LionCog.placeholder_group
|
||||||
|
|||||||
@@ -69,9 +69,25 @@ class MenuStyleParam(ChoicedEnum):
|
|||||||
)
|
)
|
||||||
@appcmds.guild_only
|
@appcmds.guild_only
|
||||||
async def rolemenu_ctxcmd(interaction: discord.Interaction, message: discord.Message):
|
async def rolemenu_ctxcmd(interaction: discord.Interaction, message: discord.Message):
|
||||||
# TODO: Permission wards!
|
bot: LionBot = interaction.client
|
||||||
bot = interaction.client
|
self: RoleMenuCog = bot.get_cog('RoleMenuCog')
|
||||||
self = 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)
|
await interaction.response.defer(thinking=True, ephemeral=True)
|
||||||
# Lookup the rolemenu in the active message cache
|
# Lookup the rolemenu in the active message cache
|
||||||
|
|||||||
Reference in New Issue
Block a user