fix(moderation): fixed errors trying to fetch the roles of a user object
All checks were successful
Pylint / Pylint (3.10) (push) Successful in 54s

This commit is contained in:
Seaswimmer 2023-10-22 14:10:13 -04:00
parent d752484662
commit 24d756b901
No known key found for this signature in database
GPG key ID: 5019678FD9CF50D8

View file

@ -177,12 +177,16 @@ class Moderation(commands.Cog):
not_found_list.append(item) not_found_list.append(item)
return not_found_list return not_found_list
def check_permissions(self, member: discord.Member, permissions: list, ctx: Union[commands.Context, discord.Interaction] = None): def check_permissions(self, user: discord.User, permissions: list, guild: discord.Guild = None, ctx: Union[commands.Context, discord.Interaction] = None):
"""Checks if the bot has a specific permission (or a list of permissions) in a channel.""" """Checks if the bot has a specific permission (or a list of permissions) in a channel."""
if ctx: if ctx:
member = ctx.guild.get_member(user.id)
resolved_permissions = ctx.channel.permissions_for(member) resolved_permissions = ctx.channel.permissions_for(member)
else: elif guild:
member = guild.get_member(user.id)
resolved_permissions = member.guild_permissions resolved_permissions = member.guild_permissions
else:
raise(KeyError)
for permission in permissions: for permission in permissions:
if not getattr(resolved_permissions, permission, False) and not resolved_permissions.administrator is True: if not getattr(resolved_permissions, permission, False) and not resolved_permissions.administrator is True:
return permission return permission