From 3b776fc972d51dc80c7c22df918318c6d900a5d4 Mon Sep 17 00:00:00 2001 From: Skillet Date: Tue, 18 Apr 2023 00:07:20 -0400 Subject: [PATCH] fixes --- autowl/Cogs/Group.py | 17 ++++++++++------- autowl/bot.py | 4 ++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/autowl/Cogs/Group.py b/autowl/Cogs/Group.py index ab66e9e..4852a4e 100644 --- a/autowl/Cogs/Group.py +++ b/autowl/Cogs/Group.py @@ -27,14 +27,17 @@ class Group(commands.Cog, name="group"): membsup = [] for memb in role.members: membsup.append(memb.id) - memupcur = self.client.squadjs.cursor(buffered=True) - in_params = ','.join(['%s'] * len(membsup)) - sqlstate = "SELECT * FROM DBLog_SteamUsers WHERE discordID IN (%s)" % in_params - memupcur.execute(sqlstate, membsup) + if len(membsup) > 0: + memupcur = self.client.squadjs.cursor(buffered=True) + in_params = ','.join(['%s'] * len(membsup)) + sqlstate = "SELECT * FROM DBLog_SteamUsers WHERE discordID IN (%s)" % in_params + log.info(sqlstate) + memupcur.execute(sqlstate, membsup) + + udata = memupcur.fetchall() + for data in udata: + self.client.whitelistGrps[role.id].addMember(config.WhitelistMember(data[2], data[1], data[0])) - udata = memupcur.fetchall() - for data in udata: - self.client.whitelistGrps[role.id].addMember(config.WhitelistMember(data[2], data[1], data[0])) await interaction.response.send_message("Whitelist group successfully added/updated") self.client.squadjs.commit() diff --git a/autowl/bot.py b/autowl/bot.py index 8138134..71ced64 100644 --- a/autowl/bot.py +++ b/autowl/bot.py @@ -75,7 +75,7 @@ class Bot(commands.Bot): rmroles.remove(aftrole.id) log.info(f"roles found to remove from {disusername}: {rmroles}") for rmroleid in rmroles: - if not rmroleid in self.whitelistGrps.keys(): + if not(rmroleid in self.whitelistGrps.keys()): continue self.whitelistGrps[rmroleid].delMember(before.id) @@ -88,7 +88,7 @@ class Bot(commands.Bot): addroles.remove(befrole.id) log.info(f"roles found to add to {disusername}: {addroles}") for addroleid in addroles: - if not addroleid in self.whitelistGrps.keys(): + if not(addroleid in self.whitelistGrps.keys()): continue self.whitelistGrps[addroleid].addMember(config.WhitelistMember(after.id, disusername, userdata[0])) self.squadjs.commit()