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
All checks were successful
Pylint / Pylint (3.10) (push) Successful in 54s
This commit is contained in:
parent
d752484662
commit
24d756b901
1 changed files with 6 additions and 2 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue