Fixed exporting weights for users that left the server

and reduced debug output
This commit is contained in:
Matthias Nadler 2019-04-14 01:09:11 +02:00
parent ae77a1f860
commit 891b79d0df
2 changed files with 6 additions and 2 deletions

View File

@ -796,7 +796,7 @@ class Poll:
if not name: if not name:
name = member.name name = member.name
export += f'\n{name}' export += f'\n{name}'
if self.votes[str(member.id)]['weight'] != 1: if self.votes[str(user_id)]['weight'] != 1:
export += f' (weight: {self.votes[str(user_id)]["weight"]})' export += f' (weight: {self.votes[str(user_id)]["weight"]})'
export += ': ' + ', '.join([self.options_reaction[c] for c in self.votes[str(user_id)]['choices']]) export += ': ' + ', '.join([self.options_reaction[c] for c in self.votes[str(user_id)]['choices']])
export += '\n' export += '\n'

View File

@ -1,5 +1,8 @@
import logging
import discord import discord
logger = logging.getLogger('bot')
class MessageCache: class MessageCache:
def __init__(self, _bot): def __init__(self, _bot):
@ -8,7 +11,8 @@ class MessageCache:
def put(self, key, value: discord.Message): def put(self, key, value: discord.Message):
self._cache_dict[key] = value self._cache_dict[key] = value
print("cache size:", self._cache_dict.__len__()) if self._cache_dict.__len__() % 5 == 0:
logger.info("cache size:", self._cache_dict.__len__())
def get(self, key): def get(self, key):
# Try to find it in this cache, then see if it is cached in the bots own message cache # Try to find it in this cache, then see if it is cached in the bots own message cache