mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-07 11:48:55 -05:00
parent
701259158f
commit
db03faf042
@ -186,13 +186,23 @@ class RedBase(commands.GroupMixin, commands.bot.BotBase, RPCMixin):
|
|||||||
async def is_admin(self, member: discord.Member):
|
async def is_admin(self, member: discord.Member):
|
||||||
"""Checks if a member is an admin of their guild."""
|
"""Checks if a member is an admin of their guild."""
|
||||||
admin_role = await self.db.guild(member.guild).admin_role()
|
admin_role = await self.db.guild(member.guild).admin_role()
|
||||||
return any(role.id == admin_role for role in member.roles)
|
try:
|
||||||
|
if any(role.id == admin_role for role in member.roles):
|
||||||
|
return True
|
||||||
|
except AttributeError: # someone passed a webhook to this
|
||||||
|
pass
|
||||||
|
return False
|
||||||
|
|
||||||
async def is_mod(self, member: discord.Member):
|
async def is_mod(self, member: discord.Member):
|
||||||
"""Checks if a member is a mod or admin of their guild."""
|
"""Checks if a member is a mod or admin of their guild."""
|
||||||
mod_role = await self.db.guild(member.guild).mod_role()
|
mod_role = await self.db.guild(member.guild).mod_role()
|
||||||
admin_role = await self.db.guild(member.guild).admin_role()
|
admin_role = await self.db.guild(member.guild).admin_role()
|
||||||
return any(role.id in (mod_role, admin_role) for role in member.roles)
|
try:
|
||||||
|
if any(role.id in (mod_role, admin_role) for role in member.roles):
|
||||||
|
return True
|
||||||
|
except AttributeError: # someone passed a webhook to this
|
||||||
|
pass
|
||||||
|
return False
|
||||||
|
|
||||||
async def get_context(self, message, *, cls=commands.Context):
|
async def get_context(self, message, *, cls=commands.Context):
|
||||||
return await super().get_context(message, cls=cls)
|
return await super().get_context(message, cls=cls)
|
||||||
@ -334,7 +344,13 @@ class RedBase(commands.GroupMixin, commands.bot.BotBase, RPCMixin):
|
|||||||
ids_to_check = [to_check.id]
|
ids_to_check = [to_check.id]
|
||||||
else:
|
else:
|
||||||
author = getattr(to_check, "author", to_check)
|
author = getattr(to_check, "author", to_check)
|
||||||
|
try:
|
||||||
ids_to_check = [r.id for r in author.roles]
|
ids_to_check = [r.id for r in author.roles]
|
||||||
|
except AttributeError:
|
||||||
|
# webhook messages are a user not member,
|
||||||
|
# cheaper than isinstance
|
||||||
|
return True # webhooks require significant permissions to enable.
|
||||||
|
else:
|
||||||
ids_to_check.append(author.id)
|
ids_to_check.append(author.id)
|
||||||
|
|
||||||
immune_ids = await self.db.guild(guild).autoimmune_ids()
|
immune_ids = await self.db.guild(guild).autoimmune_ids()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user