Finish the addrole/removerole commands and surrounding functionality #24
1 changed files with 14 additions and 0 deletions
|
@ -122,6 +122,20 @@ class Aurora(commands.Cog):
|
||||||
except ConnectionRefusedError:
|
except ConnectionRefusedError:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@commands.Cog.listener("on_member_join")
|
||||||
|
async def addrole_on_member_join(self, member: discord.Member):
|
||||||
|
"""This method automatically adds roles to users when they join the server."""
|
||||||
|
if not await self.bot.cog_disabled_in_guild(self, member.guild):
|
||||||
|
query = f"""SELECT moderation_id, role_id, reason FROM moderation_{member.guild.id} WHERE target_id = ? AND action = 'ADDROLE' AND expired = 0 AND resolved = 0;"""
|
||||||
|
database = connect()
|
||||||
|
cursor = database.cursor()
|
||||||
|
cursor.execute(query, (member.id,))
|
||||||
|
results = cursor.fetchall()
|
||||||
|
for result in results:
|
||||||
|
role = member.guild.get_role(result[1])
|
||||||
|
reason = result[2]
|
||||||
|
await member.add_roles(role, reason=f"Role automatically added on member rejoin for: {reason} (Case #{result[0]:,})")
|
||||||
|
|
||||||
@commands.Cog.listener("on_audit_log_entry_create")
|
@commands.Cog.listener("on_audit_log_entry_create")
|
||||||
async def autologger(self, entry: discord.AuditLogEntry):
|
async def autologger(self, entry: discord.AuditLogEntry):
|
||||||
"""This method automatically logs moderations done by users manually ("right clicks")."""
|
"""This method automatically logs moderations done by users manually ("right clicks")."""
|
||||||
|
|
Loading…
Reference in a new issue