diff --git a/src/modules/ranks/cog.py b/src/modules/ranks/cog.py index 6cffbe99..5ffd4cca 100644 --- a/src/modules/ranks/cog.py +++ b/src/modules/ranks/cog.py @@ -457,7 +457,7 @@ class RankCog(LionCog): @LionCog.placeholder_group @cmds.hybrid_group('configure', with_app_command=False) async def configure_group(self, ctx: LionContext): - ... + pass @configure_group.command( name=_p('cmd:configure_ranks', "ranks"), diff --git a/src/modules/ranks/ui/overview.py b/src/modules/ranks/ui/overview.py index d6e2ff03..bac9c0e1 100644 --- a/src/modules/ranks/ui/overview.py +++ b/src/modules/ranks/ui/overview.py @@ -145,7 +145,24 @@ class RankOverviewUI(MessageUI): or throw an error if the role is @everyone or not manageable by the client. """ role: discord.Role = selected.values[0] - if role.is_assignable(): + if role >= selection.user.top_role: + # Do not allow user to manage a role above their own top role + t = self.bot.translator.t + error = t(_p( + 'ui:rank_overview|menu:roles|error:above_caller', + "You have insufficient permissions to assign {mention} as a rank role! " + "You may only manage roles below your top role." + )) + embed = discord.Embed( + title=t(_p( + 'ui:rank_overview|menu:roles|error:above_caller|title', + "Insufficient permissions!" + )), + description=error, + colour=discord.Colour.brand_red() + ) + await selection.response.send_message(embed=embed, ephemeral=True) + elif role.is_assignable(): existing = next((rank for rank in self.ranks if rank.roleid == role.id), None) if existing: # Display and edit the given role diff --git a/src/modules/ranks/ui/preview.py b/src/modules/ranks/ui/preview.py index 7d58d3af..2f437680 100644 --- a/src/modules/ranks/ui/preview.py +++ b/src/modules/ranks/ui/preview.py @@ -212,7 +212,23 @@ class RankPreviewUI(MessageUI): role: discord.Role = selected.values[0] await selection.response.defer(thinking=True, ephemeral=True) - if role.is_assignable(): + if role >= selection.user.top_role: + # Do not allow user to manage a role above their own top role + error = t(_p( + 'ui:rank_preview|menu:roles|error:above_caller', + "You have insufficient permissions to assign {mention} as a rank role! " + "You may only manage roles below your top role." + )) + embed = discord.Embed( + title=t(_p( + 'ui:rank_preview|menu:roles|error:above_caller|title', + "Insufficient permissions!" + )), + description=error, + colour=discord.Colour.brand_red() + ) + await selection.response.send_message(embed=embed, ephemeral=True) + elif role.is_assignable(): # Update the rank role await self.rank.update(roleid=role.id) if self.parent is not None and not self.parent.is_finished():