Compare commits
No commits in common. "877f5e00d30264adde59afcf308b52394ca9a662" and "1a74ce9130bfbc3908cd34f5d87fb1f927c54afc" have entirely different histories.
877f5e00d3
...
1a74ce9130
1 changed files with 15 additions and 12 deletions
|
@ -117,7 +117,7 @@ class Aurora(commands.Cog):
|
||||||
async def addrole_on_member_join(self, member: discord.Member):
|
async def addrole_on_member_join(self, member: discord.Member):
|
||||||
"""This method automatically adds roles to users when they join the server."""
|
"""This method automatically adds roles to users when they join the server."""
|
||||||
if not await self.bot.cog_disabled_in_guild(self, member.guild):
|
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 moderation_type = 'ADDROLE' AND expired = 0 AND resolved = 0;"""
|
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()
|
database = connect()
|
||||||
cursor = database.cursor()
|
cursor = database.cursor()
|
||||||
cursor.execute(query, (member.id,))
|
cursor.execute(query, (member.id,))
|
||||||
|
@ -1694,8 +1694,13 @@ class Aurora(commands.Cog):
|
||||||
try:
|
try:
|
||||||
member = await guild.fetch_member(target_id)
|
member = await guild.fetch_member(target_id)
|
||||||
|
|
||||||
|
role = guild.get_role(role_id)
|
||||||
|
if role is None:
|
||||||
|
logger.warning("Role %s does not exist in %s, unable to remove role from user %s", role_id, guild.id, target_id)
|
||||||
|
continue
|
||||||
|
|
||||||
await member.remove_roles(
|
await member.remove_roles(
|
||||||
role_id, reason=f"Automatic role removal from case #{moderation_id}"
|
role, reason=f"Automatic role removal from case #{moderation_id}"
|
||||||
)
|
)
|
||||||
|
|
||||||
removerole_num = removerole_num + 1
|
removerole_num = removerole_num + 1
|
||||||
|
@ -1703,13 +1708,7 @@ class Aurora(commands.Cog):
|
||||||
discord.errors.NotFound,
|
discord.errors.NotFound,
|
||||||
discord.errors.Forbidden,
|
discord.errors.Forbidden,
|
||||||
discord.errors.HTTPException,
|
discord.errors.HTTPException,
|
||||||
) as e:
|
):
|
||||||
logger.error(
|
|
||||||
"Removing the role %s from user %s failed due to: \n%s",
|
|
||||||
role_id,
|
|
||||||
target_id,
|
|
||||||
e,
|
|
||||||
)
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
addrole_num = 0
|
addrole_num = 0
|
||||||
|
@ -1729,8 +1728,13 @@ class Aurora(commands.Cog):
|
||||||
try:
|
try:
|
||||||
member = await guild.fetch_member(target_id)
|
member = await guild.fetch_member(target_id)
|
||||||
|
|
||||||
|
role = guild.get_role(role_id)
|
||||||
|
if role is None:
|
||||||
|
logger.warning("Role %s does not exist in %s, unable to add role to user %s", role_id, guild.id, target_id)
|
||||||
|
continue
|
||||||
|
|
||||||
await member.add_roles(
|
await member.add_roles(
|
||||||
role_id, reason=f"Automatic role addition from case #{moderation_id}"
|
role, reason=f"Automatic role addition from case #{moderation_id}"
|
||||||
)
|
)
|
||||||
|
|
||||||
addrole_num = addrole_num + 1
|
addrole_num = addrole_num + 1
|
||||||
|
@ -1738,8 +1742,7 @@ class Aurora(commands.Cog):
|
||||||
discord.errors.NotFound,
|
discord.errors.NotFound,
|
||||||
discord.errors.Forbidden,
|
discord.errors.Forbidden,
|
||||||
discord.errors.HTTPException,
|
discord.errors.HTTPException,
|
||||||
) as e:
|
):
|
||||||
logger.error("Adding the role %s to user %s failed due to: \n%s", role_id, target_id, e)
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
expiry_query = f"UPDATE `moderation_{guild.id}` SET expired = 1 WHERE (end_timestamp != 0 AND end_timestamp <= ? AND expired = 0) OR (expired = 0 AND resolved = 1);"
|
expiry_query = f"UPDATE `moderation_{guild.id}` SET expired = 1 WHERE (end_timestamp != 0 AND end_timestamp <= ? AND expired = 0) OR (expired = 0 AND resolved = 1);"
|
||||||
|
|
Loading…
Add table
Reference in a new issue