Compare commits

..

2 commits

Author SHA1 Message Date
eb1cd6aada
fix(moderator): fixed fetching deleted users' cases
All checks were successful
Pylint / Pylint (push) Successful in 1m12s
2023-10-05 16:55:18 -04:00
bf8032de62
fix(moderation): cog_unload is now a coroutine 2023-10-05 16:44:54 -04:00

View file

@ -25,7 +25,7 @@ class Moderation(commands.Cog):
ignore_other_bots = True
)
disable_dateutil()
self.handle_expiry.start()
self.handle_expiry.start() # pylint: disable=no-member
async def cog_load(self):
"""This method prepares the database schema for all of the guilds the bot is currently in."""
@ -45,8 +45,8 @@ class Moderation(commands.Cog):
except ConnectionRefusedError:
return
def cog_unload(self):
self.handle_expiry.cancel()
async def cog_unload(self):
self.handle_expiry.cancel() # pylint: disable=no-member
@commands.Cog.listener('on_guild_join')
async def db_generate_guild_join(self, guild: discord.Guild):
@ -381,16 +381,36 @@ class Moderation(commands.Cog):
}
try:
target = await interaction.client.fetch_user(case["target_id"])
target_user = {
'id': target.id,
'name': target.name,
'discriminator': target.discriminator
}
except discord.errors.NotFound:
target = discord.User(id=case["target_id"], name="Deleted User", discriminator="0")
target = discord.User(id=case["target_id"], name="Deleted User", discriminator="0") # pylint: disable=unexpected-keyword-arg, missing-kwoa
target_user = {
'id': case['target_id'],
'name': 'Deleted User',
'discriminator': '0'
}
try:
moderator = await interaction.client.fetch_user(case["moderator_id"])
moderator_user = {
'id': moderator.id,
'name': moderator.name,
'discriminator': moderator.discriminator
}
except discord.errors.NotFound:
moderator = discord.User(id=case["moderator_id"], name="Deleted User", discriminator="0")
target_name = target.name if target.discriminator == "0" else f"{target.name}#{target.discriminator}"
moderator_name = moderator.name if moderator.discriminator == "0" else f"{moderator.name}#{moderator.discriminator}"
moderator = discord.User(id=case["moderator_id"], name="Deleted User", discriminator="0") # pylint: disable=unexpected-keyword-arg, missing-kwoa
moderator_user = {
'id': case['moderator_id'],
'name': 'Deleted User',
'discriminator': '0'
}
target_name = target_user['name'] if target_user['discriminator'] == "0" else f"{target_user['name']}#{target_user['discriminator']}"
moderator_name = moderator_user['name'] if moderator_user['discriminator'] == "0" else f"{moderator_user['name']}#{moderator_user['discriminator']}"
embed = discord.Embed(title=f"📕 Case #{case['moderation_id']}", color=await self.bot.get_embed_color(None))
embed.description = f"**Type:** {str.title(case['moderation_type'])}\n**Target:** {target_name} ({target.id})\n**Moderator:** {moderator_name} ({moderator.id})\n**Resolved:** {bool(case['resolved'])}\n**Timestamp:** <t:{case['timestamp']}> | <t:{case['timestamp']}:R>"
embed.description = f"**Type:** {str.title(case['moderation_type'])}\n**Target:** {target_name} ({target_user['id']})\n**Moderator:** {moderator_name} ({moderator_user['id']})\n**Resolved:** {bool(case['resolved'])}\n**Timestamp:** <t:{case['timestamp']}> | <t:{case['timestamp']}:R>"
if case['duration'] != 'NULL':
td = timedelta(**{unit: int(val) for unit, val in zip(["hours", "minutes", "seconds"], case["duration"].split(":"))})
duration_embed = f"{humanize.precisedelta(td)} | <t:{case['end_timestamp']}:R>" if case["expired"] == '0' else str(humanize.precisedelta(td))