From 52c26b34a3c22f1f526657210bcef9b0521444c8 Mon Sep 17 00:00:00 2001 From: Myned Date: Tue, 5 Jul 2022 17:19:25 -0500 Subject: [PATCH] Fix cache miss on startup --- tasks/activity.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tasks/activity.py b/tasks/activity.py index a84c6ae..e06fbc9 100644 --- a/tasks/activity.py +++ b/tasks/activity.py @@ -16,7 +16,9 @@ db = sqlitedict.SqliteDict(c.config["db"], tablename=str(c.config["guild"]), aut async def check_activity(): for author_id, timestamp in db.items(): if dt.datetime.now(dt.timezone.utc) - timestamp >= dt.timedelta(seconds=c.config["duration"]): - member = plugin.bot.cache.get_member(c.config["guild"], author_id) + member = plugin.bot.cache.get_member(c.config["guild"], author_id) or await plugin.bot.rest.fetch_member( + c.config["guild"], author_id + ) if c.config["active"] and c.config["active"] in member.role_ids: await member.remove_role(c.config["active"])