mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-07 11:48:55 -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": _(
|
||||
"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."),
|
||||
"permissions_issue_role": _(
|
||||
"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
|
||||
await ctx.send(_("Channel overwrites will be used for mutes instead."))
|
||||
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)
|
||||
self.mute_role_cache[ctx.guild.id] = role.id
|
||||
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:
|
||||
ret["reason"] = _(MUTE_UNMUTE_ISSUES["role_missing"])
|
||||
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:
|
||||
ret["reason"] = _(MUTE_UNMUTE_ISSUES["permissions_issue_role"])
|
||||
return ret
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user