mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 02:16:09 -05:00
[Core] Multiple mod admin roles (#2783)
* Adds Schema versioning - Adds Migration tool - Adds tool to migrate to allow multiple admin and mod roles - Supports Multiple mod and admin roles * Ensures migration is run prior to cog load and connection to discord * Updates to not rely on singular mod/admin role id * Update requires logic for multiple mod/admin roles * Add new commands for managing mod/admin roles * Feedback Update strings Update docstrings Add aliases * Use snowflakelist * paginate * Change variable name * Fix mistake * handle settings view fix * Fix name error * I'm bad at Ux * style fix
This commit is contained in:
@@ -3051,34 +3051,29 @@ class Audio(commands.Cog):
|
||||
return await self._skip_action(ctx, skip_to_track)
|
||||
|
||||
async def _can_instaskip(self, ctx, member):
|
||||
mod_role = await ctx.bot.db.guild(ctx.guild).mod_role()
|
||||
admin_role = await ctx.bot.db.guild(ctx.guild).admin_role()
|
||||
|
||||
dj_enabled = await self.config.guild(ctx.guild).dj_enabled()
|
||||
|
||||
if dj_enabled:
|
||||
is_active_dj = await self._has_dj_role(ctx, member)
|
||||
else:
|
||||
is_active_dj = False
|
||||
is_owner = member.id == self.bot.owner_id
|
||||
is_server_owner = member.id == ctx.guild.owner_id
|
||||
is_coowner = any(x == member.id for x in self.bot._co_owners)
|
||||
is_admin = (
|
||||
discord.utils.get(ctx.guild.get_member(member.id).roles, id=admin_role) is not None
|
||||
)
|
||||
is_mod = discord.utils.get(ctx.guild.get_member(member.id).roles, id=mod_role) is not None
|
||||
is_bot = member.bot is True
|
||||
is_other_channel = await self._channel_check(ctx)
|
||||
if member.bot:
|
||||
return True
|
||||
|
||||
return (
|
||||
is_active_dj
|
||||
or is_owner
|
||||
or is_server_owner
|
||||
or is_coowner
|
||||
or is_admin
|
||||
or is_mod
|
||||
or is_bot
|
||||
or is_other_channel
|
||||
)
|
||||
if member.id == ctx.guild.owner_id:
|
||||
return True
|
||||
|
||||
if dj_enabled:
|
||||
if await self._has_dj_role(ctx, member):
|
||||
return True
|
||||
|
||||
if await ctx.bot.is_owner(member):
|
||||
return True
|
||||
|
||||
if await ctx.bot.is_mod(member):
|
||||
return True
|
||||
|
||||
if await self._channel_check(ctx):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
async def _is_alone(self, ctx, member):
|
||||
try:
|
||||
|
||||
@@ -43,10 +43,14 @@ def check_global_setting_admin():
|
||||
return False
|
||||
if await ctx.bot.is_owner(author):
|
||||
return True
|
||||
permissions = ctx.channel.permissions_for(author)
|
||||
is_guild_owner = author == ctx.guild.owner
|
||||
admin_role = await ctx.bot.db.guild(ctx.guild).admin_role()
|
||||
return admin_role in author.roles or is_guild_owner or permissions.manage_guild
|
||||
if author == ctx.guild.owner:
|
||||
return True
|
||||
if ctx.channel.permissions_for(author).manage_guild:
|
||||
return True
|
||||
admin_roles = set(await ctx.bot.db.guild(ctx.guild).admin_role())
|
||||
for role in author.roles:
|
||||
if role.id in admin_roles:
|
||||
return True
|
||||
else:
|
||||
return await ctx.bot.is_owner(author)
|
||||
|
||||
|
||||
@@ -84,18 +84,14 @@ class Reports(commands.Cog):
|
||||
await ctx.send(_("Reporting is now disabled."))
|
||||
|
||||
async def internal_filter(self, m: discord.Member, mod=False, perms=None):
|
||||
ret = False
|
||||
if mod:
|
||||
guild = m.guild
|
||||
admin_role = guild.get_role(await self.bot.db.guild(guild).admin_role())
|
||||
mod_role = guild.get_role(await self.bot.db.guild(guild).mod_role())
|
||||
ret |= any(r in m.roles for r in (mod_role, admin_role))
|
||||
if perms:
|
||||
ret |= m.guild_permissions >= perms
|
||||
if perms and m.guild_permissions >= perms:
|
||||
return True
|
||||
if mod and await self.bot.is_mod(m):
|
||||
return True
|
||||
# The following line is for consistency with how perms are handled
|
||||
# in Red, though I'm not sure it makse sense to use here.
|
||||
ret |= await self.bot.is_owner(m)
|
||||
return ret
|
||||
# in Red, though I'm not sure it makes sense to use here.
|
||||
if await self.bot.is_owner(m):
|
||||
return True
|
||||
|
||||
async def discover_guild(
|
||||
self,
|
||||
|
||||
Reference in New Issue
Block a user