mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-20 09:56:05 -05:00
Deprecate is_allowed_by_hierarchy() core util (#4435)
This commit is contained in:
@@ -9,9 +9,10 @@ from redbot.core import commands, i18n, checks, modlog
|
||||
from redbot.core.commands import UserInputOptional
|
||||
from redbot.core.utils import AsyncIter
|
||||
from redbot.core.utils.chat_formatting import pagify, humanize_number, bold, humanize_list
|
||||
from redbot.core.utils.mod import is_allowed_by_hierarchy, get_audit_reason
|
||||
from redbot.core.utils.mod import get_audit_reason
|
||||
from .abc import MixinMeta
|
||||
from .converters import RawUserIds
|
||||
from .utils import is_allowed_by_hierarchy
|
||||
|
||||
log = logging.getLogger("red.mod")
|
||||
_ = i18n.Translator("Mod", __file__)
|
||||
|
||||
@@ -6,8 +6,9 @@ import discord
|
||||
from redbot.core import commands, checks, i18n, modlog
|
||||
from redbot.core.utils import AsyncIter
|
||||
from redbot.core.utils.chat_formatting import format_perms_list
|
||||
from redbot.core.utils.mod import get_audit_reason, is_allowed_by_hierarchy
|
||||
from redbot.core.utils.mod import get_audit_reason
|
||||
from .abc import MixinMeta
|
||||
from .utils import is_allowed_by_hierarchy
|
||||
|
||||
T_ = i18n.Translator("Mod", __file__)
|
||||
|
||||
|
||||
13
redbot/cogs/mod/utils.py
Normal file
13
redbot/cogs/mod/utils.py
Normal file
@@ -0,0 +1,13 @@
|
||||
import discord
|
||||
|
||||
from redbot.core.bot import Red
|
||||
from redbot.core.config import Config
|
||||
|
||||
|
||||
async def is_allowed_by_hierarchy(
|
||||
bot: Red, config: Config, guild: discord.Guild, mod: discord.Member, user: discord.Member
|
||||
):
|
||||
if not await config.guild(guild).respect_hierarchy():
|
||||
return True
|
||||
is_special = mod == guild.owner or await bot.is_owner(mod)
|
||||
return mod.top_role.position > user.top_role.position or is_special
|
||||
Reference in New Issue
Block a user