diff --git a/moderation/moderation.py b/moderation/moderation.py index c75e5b0..82e0bbb 100644 --- a/moderation/moderation.py +++ b/moderation/moderation.py @@ -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.""" @@ -46,7 +46,7 @@ class Moderation(commands.Cog): return async def cog_unload(self): - self.handle_expiry.cancel() + 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:** | " + 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:** | " 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)} | " if case["expired"] == '0' else str(humanize.precisedelta(td))