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

Add removal of activity roles for excluded role

Only takes effect on message/voice
This commit is contained in:
Myned 2022-08-16 17:38:44 -05:00
parent c5376f6c6e
commit d76cb084e2
No known key found for this signature in database
GPG key ID: 28056631D2CF6B1B

View file

@ -45,8 +45,15 @@ async def on_ready(event):
# Listener for guild messages # Listener for guild messages
@plugin.listener(hikari.GuildMessageCreateEvent) @plugin.listener(hikari.GuildMessageCreateEvent)
async def on_message(event): async def on_message(event):
# Exclude bots, unselected guild, and excluded role # Exclude bots and other guilds
if event.is_bot or event.guild_id != c.config["guild"] or c.config["exclude"] in event.member.role_ids: if event.is_bot or event.guild_id != c.config["guild"]:
return
# Exclude and remove activity roles from excluded role
if c.config["exclude"] in event.member.role_ids:
if c.config["active"] in event.member.role_ids:
await event.member.remove_role(c.config["active"])
if c.config["inactive"] in event.member.role_ids:
await event.member.remove_role(c.config["inactive"])
return return
# Insert current timestamp into db # Insert current timestamp into db
@ -62,12 +69,15 @@ async def on_message(event):
# Listener for voice state # Listener for voice state
@plugin.listener(hikari.VoiceStateUpdateEvent) @plugin.listener(hikari.VoiceStateUpdateEvent)
async def on_voice(event): async def on_voice(event):
# Exclude bots, unselected guild, and excluded role # Exclude bots and other guilds
if ( if event.state.member.is_bot or event.guild_id != c.config["guild"]:
event.state.member.is_bot return
or event.guild_id != c.config["guild"] # Exclude and remove activity roles from excluded role
or c.config["exclude"] in event.state.member.role_ids if c.config["exclude"] in event.state.member.role_ids:
): if c.config["active"] in event.state.member.role_ids:
await event.state.member.remove_role(c.config["active"])
if c.config["inactive"] in event.state.member.role_ids:
await event.state.member.remove_role(c.config["inactive"])
return return
# Insert current timestamp into db # Insert current timestamp into db