Compare commits
3 commits
818ff810ea
...
7c8aaba309
Author | SHA1 | Date | |
---|---|---|---|
7c8aaba309 | |||
c82aa6a0f5 | |||
10cfeeefcd |
1 changed files with 56 additions and 53 deletions
109
aurora/aurora.py
109
aurora/aurora.py
|
@ -46,7 +46,7 @@ class Aurora(commands.Cog):
|
||||||
This cog stores all of its data in an SQLite database."""
|
This cog stores all of its data in an SQLite database."""
|
||||||
|
|
||||||
__author__ = ["Seaswimmer"]
|
__author__ = ["Seaswimmer"]
|
||||||
__version__ = "3.0.0-indev1"
|
__version__ = "3.0.0-indev2"
|
||||||
__documentation__ = "https://seacogs.coastalcommits.com/aurora/"
|
__documentation__ = "https://seacogs.coastalcommits.com/aurora/"
|
||||||
|
|
||||||
async def red_delete_data_for_user(self, *, requester, user_id: int):
|
async def red_delete_data_for_user(self, *, requester, user_id: int):
|
||||||
|
@ -113,7 +113,7 @@ class Aurora(commands.Cog):
|
||||||
self.handle_expiry.cancel()
|
self.handle_expiry.cancel()
|
||||||
|
|
||||||
@commands.Cog.listener("on_guild_join")
|
@commands.Cog.listener("on_guild_join")
|
||||||
async def db_generate_guild_join(self, guild: discord.Guild):
|
async def db_generate_on_guild_join(self, guild: discord.Guild):
|
||||||
"""This method prepares the database schema whenever the bot joins a guild."""
|
"""This method prepares the database schema whenever the bot joins a guild."""
|
||||||
if not await self.bot.cog_disabled_in_guild(self, guild):
|
if not await self.bot.cog_disabled_in_guild(self, guild):
|
||||||
try:
|
try:
|
||||||
|
@ -126,7 +126,7 @@ class Aurora(commands.Cog):
|
||||||
"""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 moderation_type = 'ADDROLE' AND expired = 0 AND resolved = 0;"""
|
||||||
results = Moderation.execute(query, (member.id,))
|
results = await Moderation.execute(query, (member.id,))
|
||||||
for row in results:
|
for row in results:
|
||||||
role = member.guild.get_role(row[1])
|
role = member.guild.get_role(row[1])
|
||||||
reason = row[2]
|
reason = row[2]
|
||||||
|
@ -135,58 +135,61 @@ class Aurora(commands.Cog):
|
||||||
@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")."""
|
||||||
if not await self.bot.cog_disabled_in_guild(self, entry.guild):
|
try:
|
||||||
if await config.guild(entry.guild).ignore_other_bots() is True:
|
if not await self.bot.cog_disabled_in_guild(self, entry.guild):
|
||||||
if entry.user.bot or entry.target.bot:
|
if await config.guild(entry.guild).ignore_other_bots() is True:
|
||||||
return
|
if entry.user.bot or entry.target.bot:
|
||||||
else:
|
return
|
||||||
if entry.user.id == self.bot.user.id:
|
|
||||||
return
|
|
||||||
|
|
||||||
duration = None
|
|
||||||
|
|
||||||
if entry.reason:
|
|
||||||
reason = entry.reason + " (This action was performed without the bot.)"
|
|
||||||
|
|
||||||
else:
|
|
||||||
reason = "This action was performed without the bot."
|
|
||||||
|
|
||||||
if entry.action == discord.AuditLogAction.kick:
|
|
||||||
moderation_type = "KICK"
|
|
||||||
|
|
||||||
elif entry.action == discord.AuditLogAction.ban:
|
|
||||||
moderation_type = "BAN"
|
|
||||||
|
|
||||||
elif entry.action == discord.AuditLogAction.unban:
|
|
||||||
moderation_type = "UNBAN"
|
|
||||||
|
|
||||||
elif entry.action == discord.AuditLogAction.member_update:
|
|
||||||
if entry.after.timed_out_until is not None:
|
|
||||||
timed_out_until_aware = entry.after.timed_out_until.replace(
|
|
||||||
tzinfo=timezone.utc
|
|
||||||
)
|
|
||||||
duration_datetime = timed_out_until_aware - datetime.now(
|
|
||||||
tz=timezone.utc
|
|
||||||
)
|
|
||||||
minutes = round(duration_datetime.total_seconds() / 60)
|
|
||||||
duration = timedelta(minutes=minutes)
|
|
||||||
moderation_type = "MUTE"
|
|
||||||
else:
|
else:
|
||||||
moderation_type = "UNMUTE"
|
if entry.user.id == self.bot.user.id:
|
||||||
else:
|
return
|
||||||
return
|
|
||||||
|
|
||||||
await Moderation.log(
|
duration = None
|
||||||
self.bot,
|
|
||||||
entry.guild.id,
|
if entry.reason:
|
||||||
entry.user.id,
|
reason = entry.reason + " (This action was performed without the bot.)"
|
||||||
moderation_type,
|
|
||||||
"USER",
|
else:
|
||||||
entry.target.id,
|
reason = "This action was performed without the bot."
|
||||||
None,
|
|
||||||
duration,
|
if entry.action == discord.AuditLogAction.kick:
|
||||||
reason,
|
moderation_type = "KICK"
|
||||||
)
|
|
||||||
|
elif entry.action == discord.AuditLogAction.ban:
|
||||||
|
moderation_type = "BAN"
|
||||||
|
|
||||||
|
elif entry.action == discord.AuditLogAction.unban:
|
||||||
|
moderation_type = "UNBAN"
|
||||||
|
|
||||||
|
elif entry.action == discord.AuditLogAction.member_update:
|
||||||
|
if entry.after.timed_out_until is not None:
|
||||||
|
timed_out_until_aware = entry.after.timed_out_until.replace(
|
||||||
|
tzinfo=timezone.utc
|
||||||
|
)
|
||||||
|
duration_datetime = timed_out_until_aware - datetime.now(
|
||||||
|
tz=timezone.utc
|
||||||
|
)
|
||||||
|
minutes = round(duration_datetime.total_seconds() / 60)
|
||||||
|
duration = timedelta(minutes=minutes)
|
||||||
|
moderation_type = "MUTE"
|
||||||
|
else:
|
||||||
|
moderation_type = "UNMUTE"
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
|
await Moderation.log(
|
||||||
|
self.bot,
|
||||||
|
entry.guild.id,
|
||||||
|
entry.user.id,
|
||||||
|
moderation_type,
|
||||||
|
"USER",
|
||||||
|
entry.target.id,
|
||||||
|
None,
|
||||||
|
duration,
|
||||||
|
reason,
|
||||||
|
)
|
||||||
|
except AttributeError:
|
||||||
|
return
|
||||||
|
|
||||||
#######################################################################################################################
|
#######################################################################################################################
|
||||||
### COMMANDS
|
### COMMANDS
|
||||||
|
|
Loading…
Reference in a new issue