mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-08 04:08:56 -05:00
Ensure no role hierarchy bypassing in Mutes (#4741)
* Ensure no role hierarchy bypassing on bad role configuration * Do the same for `[p]muteset role`
This commit is contained in:
parent
537656c365
commit
4138410d33
@ -28,6 +28,9 @@ MUTE_UNMUTE_ISSUES = {
|
|||||||
"hierarchy_problem": _(
|
"hierarchy_problem": _(
|
||||||
"I cannot let you do that. You are not higher than the user in the role hierarchy."
|
"I cannot let you do that. You are not higher than the user in the role hierarchy."
|
||||||
),
|
),
|
||||||
|
"assigned_role_hierarchy_problem": _(
|
||||||
|
"I cannot let you do that. You are not higher than the mute role in the role hierarchy."
|
||||||
|
),
|
||||||
"is_admin": _("That user cannot be muted, as they have the Administrator permission."),
|
"is_admin": _("That user cannot be muted, as they have the Administrator permission."),
|
||||||
"permissions_issue_role": _(
|
"permissions_issue_role": _(
|
||||||
"Failed to mute or unmute user. I need the Manage Roles "
|
"Failed to mute or unmute user. I need the Manage Roles "
|
||||||
@ -684,6 +687,11 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass):
|
|||||||
# removed the mute role
|
# removed the mute role
|
||||||
await ctx.send(_("Channel overwrites will be used for mutes instead."))
|
await ctx.send(_("Channel overwrites will be used for mutes instead."))
|
||||||
else:
|
else:
|
||||||
|
if role >= ctx.author.top_role:
|
||||||
|
await ctx.send(
|
||||||
|
_("You can't set this role as it is not lower than you in the role hierarchy.")
|
||||||
|
)
|
||||||
|
return
|
||||||
await self.config.guild(ctx.guild).mute_role.set(role.id)
|
await self.config.guild(ctx.guild).mute_role.set(role.id)
|
||||||
self.mute_role_cache[ctx.guild.id] = role.id
|
self.mute_role_cache[ctx.guild.id] = role.id
|
||||||
await ctx.send(_("Mute role set to {role}").format(role=role.name))
|
await ctx.send(_("Mute role set to {role}").format(role=role.name))
|
||||||
@ -1331,6 +1339,9 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass):
|
|||||||
if not role:
|
if not role:
|
||||||
ret["reason"] = _(MUTE_UNMUTE_ISSUES["role_missing"])
|
ret["reason"] = _(MUTE_UNMUTE_ISSUES["role_missing"])
|
||||||
return ret
|
return ret
|
||||||
|
if author != guild.owner and role >= author.top_role:
|
||||||
|
ret["reason"] = _(MUTE_UNMUTE_ISSUES["assigned_role_hierarchy_problem"])
|
||||||
|
return ret
|
||||||
if not guild.me.guild_permissions.manage_roles or role >= guild.me.top_role:
|
if not guild.me.guild_permissions.manage_roles or role >= guild.me.top_role:
|
||||||
ret["reason"] = _(MUTE_UNMUTE_ISSUES["permissions_issue_role"])
|
ret["reason"] = _(MUTE_UNMUTE_ISSUES["permissions_issue_role"])
|
||||||
return ret
|
return ret
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user