Browse Source

A warn in now also logging into mod-logs

baumsplitter41 2 months ago
parent
commit
b2d103a7bf
1 changed files with 31 additions and 10 deletions
  1. 31 10
      VPD_BOT/main.py

+ 31 - 10
VPD_BOT/main.py

@@ -414,6 +414,26 @@ async def warn(
         await ctx.followup.send("Invalid target.", ephemeral=True)
         return
     
+
+    channel= discord.utils.get(ctx.guild.channels, id = int(channel_mod_log))
+
+    embed = discord.Embed(
+        title=f"Warn of **{user.name}**",
+        description=f"User {user.mention} has been warned.",
+        color=discord.Color.red()
+    )
+    time = discord.utils.format_dt(datetime.now(), "f")
+    embed.add_field(name="Warn Date", value=time, inline=False)
+    embed.add_field(name="Moderator", value=f"{ctx.author}", inline=False)
+    embed.add_field(name="Reason", value=reason, inline=False)
+
+    embed.add_field(name="User ID", value=user.id)
+
+    embed.set_thumbnail(url=user.display_avatar.url)
+    embed.set_author(name="VicePD", icon_url="https://i.imgur.com/6QteFrg.png")
+    embed.set_footer(text="VicePD - Bot | Made by BaumSplitter41")
+    
+
     #DM to user
     embed_dm = discord.Embed(
         title=f"You have been warned on {ctx.guild.name}",
@@ -430,16 +450,17 @@ async def warn(
     except discord.Forbidden:
         await ctx.respond("Error: I can't send a DM to this user. The user was warned without a information.", ephemeral=True)
         pass  # User has DMs closed or blocked the bot
-        cursor.execute(
-            "INSERT INTO Warns (userid, username, moderatorname, reason) VALUES (%s, %s, %s, %s)",
-            (user.id, str(user), str(ctx.author), reason)
-        )
-        conn.commit()
-
-        await ctx.followup.send(
-            f"User {user.mention} has been warned for: {reason}",
-            ephemeral=True
-        )
+    cursor.execute(
+        "INSERT INTO Warns (userid, username, moderatorname, reason) VALUES (%s, %s, %s, %s)",
+        (user.id, str(user), str(ctx.author), reason)
+    )
+    conn.commit()
+    
+    await channel.send(embed=embed)
+    await ctx.followup.send(
+        f"User {user.mention} has been warned for: {reason}",
+        ephemeral=True
+    )
 
 #---------------------------------#
 #Modinfo