From 24d756b901de803493c26ffed366ab1ed8234e14 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Sun, 22 Oct 2023 14:10:13 -0400 Subject: [PATCH] fix(moderation): fixed errors trying to fetch the roles of a user object --- moderation/moderation.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/moderation/moderation.py b/moderation/moderation.py index deb2875..4b9cc57 100644 --- a/moderation/moderation.py +++ b/moderation/moderation.py @@ -177,12 +177,16 @@ class Moderation(commands.Cog): not_found_list.append(item) 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.""" if ctx: + member = ctx.guild.get_member(user.id) resolved_permissions = ctx.channel.permissions_for(member) - else: + elif guild: + member = guild.get_member(user.id) resolved_permissions = member.guild_permissions + else: + raise(KeyError) for permission in permissions: if not getattr(resolved_permissions, permission, False) and not resolved_permissions.administrator is True: return permission