From 9b418d5f6956b75a61ee3591a984152ce0229d5c Mon Sep 17 00:00:00 2001 From: jsl12 <32917998+jsl12@users.noreply.github.com> Date: Thu, 19 May 2022 21:40:36 -0500 Subject: [PATCH] added scan_messages to Kwaylon to incorporate the async lock on the database file --- src/kwaylon/kwaylon.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/kwaylon/kwaylon.py b/src/kwaylon/kwaylon.py index 64b2076..a09a396 100644 --- a/src/kwaylon/kwaylon.py +++ b/src/kwaylon/kwaylon.py @@ -109,8 +109,8 @@ class Kwaylon(Client): msg = await self.fetch_message(most) await message.reply(f'Most {emoji_ref} in past {days} days\n{msg.jump_url}') - else: - await message.reply(f"NObody (in the past {days} days)...gah, leave me alone!") + # else: + # await message.reply(f"NObody (in the past {days} days)...gah, leave me alone!") LOGGER.info(f'Done') @@ -150,6 +150,10 @@ class Kwaylon(Client): channel = await guild.fetch_channel(row['channel_id']) return await channel.fetch_message(row['msg_id']) + async def scan_messages(self, **kwargs): + async with self.lock: + await self.data.scan_messages(client=self, **kwargs) + def get_emoji_name(string: str) -> str: if (m := re.search('<:(?P\w+):(?P\d+)>', string)):