prevent duplicates from being added to the ban cache
@@ -243,13 +243,15 @@ class Database(commands.Cog):
async def set_botbanned(self, uid, botbanned):
await self.fetch_user(uid)
- if botbanned:
+ if botbanned and uid not in self.d.ban_cache:
self.d.ban_cache.append(uid)
else:
try:
self.d.ban_cache.pop(self.d.ban_cache.index(uid))
except KeyError:
pass
+ except ValueError:
+ pass
async with self.db.acquire() as con:
await con.execute('UPDATE users SET bot_banned = $1 WHERE uid = $2', botbanned, uid)
