diff --git a/chiya/cogs/mute.py b/chiya/cogs/mute.py index edc05d48..5e609d76 100644 --- a/chiya/cogs/mute.py +++ b/chiya/cogs/mute.py @@ -55,23 +55,21 @@ async def mute( if not status: return await embeds.send_error(ctx=ctx, description="Unable to decipher duration, please try again") - # TODO: Apparently arrow expects struct to be UTC but it's based on the local time instead which throws it off - muted_until = arrow.get(*struct[:6], tzinfo=arrow.now().tzinfo.zone) - logger.info(f"Before: {muted_until}") - logger.info(f"After: {muted_until.to('utc')}") - + # arrow will assume the struct is in UTC unless we manually set the timezone to the system timezone + # and then convert it to UTC afterwards. We shouldn't need to do this again unless using parsedatetime. + muted_until = arrow.get(*struct[:6]).replace(tzinfo=arrow.now().tzinfo).to("utc") if muted_until >= arrow.utcnow().shift(days=+28): return await embeds.send_error(ctx=ctx, description="Timeout duration cannot exceed 28 days.") mod_embed = embeds.make_embed( ctx=ctx, - title=f"Muting member: {member}", + title="Muted member", description=f"{member.mention} was muted by {ctx.user.mention} for: {reason}", thumbnail_url="https://files.catbox.moe/6rs4fn.png", - color=discord.Color.red(), + color=0xCD6D6D, fields=[ - {"name": "Duration:", "value": muted_until.humanize(), "inline": True}, {"name": "Expires:", "value": f"", "inline": True}, + {"name": "Reason:", "value": reason, "inline": False}, ], ) @@ -90,15 +88,7 @@ async def mute( try: await member.send(embed=user_embed) except (discord.Forbidden, discord.HTTPException): - mod_embed.add_field( - name="Notice:", - value=( - f"Unable to message {member.mention} about this action. " - "This can be caused by the user not being in the server, " - "having DMs disabled, or having the bot blocked." - ), - inline=False, - ) + mod_embed.set_footer(text="⚠️ Unable to message user about this action.") ModLog( user_id=member.id, @@ -148,10 +138,13 @@ async def unmute( mod_embed = embeds.make_embed( ctx=ctx, - title=f"Unmuting member: {member.name}", - description=f"{member.mention} was unmuted by {ctx.user.mention} for: {reason}", + title="Unmuted member", + description=f"{member.mention} was unmuted by {ctx.user.mention}", color=discord.Color.green(), thumbnail_url="https://files.catbox.moe/izm83m.png", + fields=[ + {"name": "Reason:", "value": reason, "inline": False}, + ], ) user_embed = embeds.make_embed( @@ -161,27 +154,19 @@ async def unmute( image_url="https://files.catbox.moe/razmf6.gif", color=discord.Color.blurple(), fields=[ - {"name": "Server:", "value": f"[{ctx.guild.name}]({await ctx.guild.vanity_invite()})", "inline": True}, + {"name": "Server:", "value": ctx.guild.name, "inline": True}, {"name": "Reason:", "value": reason, "inline": False}, ], ) try: await member.send(embed=user_embed) except (discord.Forbidden, discord.HTTPException): - mod_embed.add_field( - name="Notice:", - value=( - f"Unable to message {member.mention} about this action. " - "This can be caused by the user not being in the server, " - "having DMs disabled, or having the bot blocked." - ), - inline=False, - ) + mod_embed.set_footer(text="⚠️ Unable to message user about this action.") ModLog( user_id=member.id, mod_id=ctx.user.id, - timestamp=arrow.now().int_timestamp, + timestamp=arrow.utcnow().int_timestamp, reason=reason, type="unmute", ).save() @@ -198,10 +183,11 @@ async def on_member_update(self, before: discord.Member, after: discord.Member) if not before.timed_out_until and after.timed_out_until: logs = [log async for log in after.guild.audit_logs(limit=1, action=discord.AuditLogAction.member_update)] if logs[0].user != self.bot.user: + # TODO: need to log duration here ModLog( user_id=after.id, mod_id=logs[0].user.id, - timestamp=arrow.now().int_timestamp, + timestamp=arrow.utcnow().int_timestamp, reason=logs[0].reason, type="mute", ).save() @@ -212,7 +198,7 @@ async def on_member_update(self, before: discord.Member, after: discord.Member) ModLog( user_id=after.id, mod_id=logs[0].user.id, - timestamp=arrow.now().int_timestamp, + timestamp=arrow.utcnow().int_timestamp, reason=logs[0].reason, type="unmute", ) diff --git a/chiya/cogs/reminder.py b/chiya/cogs/reminder.py index 2339d6a5..a2c759d4 100644 --- a/chiya/cogs/reminder.py +++ b/chiya/cogs/reminder.py @@ -1,5 +1,3 @@ -from datetime import datetime, timedelta - import arrow import discord from discord import app_commands diff --git a/chiya/database.py b/chiya/database.py index 35c195e4..5fc64e6d 100644 --- a/chiya/database.py +++ b/chiya/database.py @@ -42,7 +42,7 @@ class ModLog(Base): mod_id = Column(Integer, nullable=False) timestamp = Column(Integer, nullable=False) reason = Column(Text, nullable=False) - duration = Column(Text, nullable=False) + duration = Column(Text, nullable=True) type = Column(Text, nullable=False)