improved error handling

This commit is contained in:
2021-08-13 12:10:15 -05:00
parent 52dbb8d17b
commit de6e5414eb
3 changed files with 18 additions and 11 deletions

View File

@@ -39,7 +39,7 @@ class RoboPage(discord.Client):
self.data: data.MsgData = await data.MsgData.create(
client=self,
limit=3000,
limit=5000,
# limit=20,
days=30,
)
@@ -48,20 +48,22 @@ class RoboPage(discord.Client):
# await alive()
async def handle_message(self, message):
await self.data.add_msg(message)
if hasattr(self, 'data'):
await self.data.add_msg(message)
if message.author != self.user:
if (m := self.leaderboard_regex.match(message.content)) is not None:
try:
await message.reply(self.data.emoji_leaderboard(emoji_name=m.group('emoji'), days=14))
await message.reply(self.data.emoji_leaderboard(emoji_name=m.group('emoji').lower(), days=14))
except KeyError as e:
LOGGER.exception(e)
await message.reply(f"I couldn't find any {m.group('emoji')} reactions. Leave me alone!")
elif (m := self.most_regex.match(message.content)) is not None:
days = m.group('days') or 14
try:
await message.reply(
await self.data.biggest_single(client=self, emoji=m.group('emoji'), days=int(days))
await self.data.biggest_single(client=self, emoji=m.group('emoji').lower(), days=int(days))
)
except IndexError as e:
await message.reply('NObody')