From f9acac86f6c894181c0cf81105d6445a9f46628e Mon Sep 17 00:00:00 2001 From: Myned Date: Tue, 14 Jun 2022 18:21:49 -0500 Subject: [PATCH] Add role excluded from activity checks --- config.py | 1 + tasks/activity.py | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/config.py b/config.py index 22c0673..8edb7b5 100644 --- a/config.py +++ b/config.py @@ -14,6 +14,7 @@ db = "watcher.db" # sqlite3 db filepath guild = 0 # guild id to watch active = 0 # active role id inactive = 0 # inactive role id +exclude = 0 # role id to exclude from activity checks duration = 0 # time in seconds before considered inactive """ diff --git a/tasks/activity.py b/tasks/activity.py index 744085f..a84c6ae 100644 --- a/tasks/activity.py +++ b/tasks/activity.py @@ -33,7 +33,7 @@ async def on_ready(event): # Listener for guild messages @plugin.listener(hikari.GuildMessageCreateEvent) async def on_message(event): - if event.is_bot or event.guild_id != c.config["guild"]: + if event.is_bot or event.guild_id != c.config["guild"] or c.config["exclude"] in event.member.role_ids: return db[event.author_id] = dt.datetime.now(dt.timezone.utc) # or event.message.timestamp @@ -47,7 +47,11 @@ async def on_message(event): # Listener for voice state @plugin.listener(hikari.VoiceStateUpdateEvent) async def on_voice(event): - if event.state.member.is_bot or event.guild_id != c.config["guild"]: + if ( + event.state.member.is_bot + or event.guild_id != c.config["guild"] + or c.config["exclude"] in event.state.member.role_ids + ): return db[event.state.user_id] = dt.datetime.now(dt.timezone.utc)