1
0
Fork 0
mirror of https://github.com/myned/watcher.git synced 2024-11-01 12:22:38 +00:00

Fix unknown members in db

This commit is contained in:
Myned 2022-07-23 22:08:59 -05:00
parent f104355a99
commit 762a9bbe51
No known key found for this signature in database
GPG key ID: 28056631D2CF6B1B

View file

@ -14,14 +14,18 @@ plugin = lightbulb.Plugin("activity")
async def check_activity():
for author_id, timestamp in c.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) or await plugin.bot.rest.fetch_member(
try:
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"])
if c.config["inactive"] and c.config["inactive"] not in member.role_ids:
await member.add_role(c.config["inactive"])
except hikari.NotFoundError:
print(f"Member {author_id} not found. Deleting entry...")
del c.db[author_id]
# Listener for bot ready