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

Add voice state activity

This commit is contained in:
Myned 2022-06-08 22:22:19 -05:00
parent 4b5b047203
commit d40ba7cdb3
No known key found for this signature in database
GPG key ID: 33790F979F7A28B8

View file

@ -36,7 +36,7 @@ async def on_message(event):
if event.is_bot or event.guild_id != c.config["guild"]:
return
db[event.author_id] = event.message.timestamp # or datetime.datetime.utcnow()
db[event.author_id] = dt.datetime.now(dt.timezone.utc) # or event.message.timestamp
if c.config["active"] and c.config["active"] not in event.member.role_ids:
await event.member.add_role(c.config["active"])
@ -44,6 +44,20 @@ async def on_message(event):
await event.member.remove_role(c.config["inactive"])
# 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"]:
return
db[event.state.user_id] = dt.datetime.now(dt.timezone.utc)
if c.config["active"] and c.config["active"] not in event.state.member.role_ids:
await event.state.member.add_role(c.config["active"])
if c.config["inactive"] and c.config["inactive"] in event.state.member.role_ids:
await event.state.member.remove_role(c.config["inactive"])
def load(bot):
bot.add_plugin(plugin)