lunarflu HF staff commited on
Commit
9627d5c
1 Parent(s): 07b9b53

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -28
app.py CHANGED
@@ -22,7 +22,7 @@ import asyncio # check if used
22
  zurich_tz = timezone("Europe/Zurich")
23
  intents = discord.Intents.all()
24
  bot = commands.Bot(command_prefix='!', intents=intents)
25
- LOG_CHANNEL = bot.get_channel(1126516932527534111)
26
  print(f"LOG_CHANNEL: {LOG_CHANNEL}")
27
  # test = 1126516932527534111
28
  # bot-test = 1100458786826747945
@@ -52,35 +52,39 @@ ping alerts for list of keywords
52
 
53
  @bot.event
54
  async def on_message_edit(before, after):
55
- if before.author == bot.user:
56
- return
57
-
58
- if before.content != after.content:
59
- embed = Embed(color=Color.orange())
60
- embed.set_author(name=f"{before.author} ID: {before.author.id}", icon_url=before.author.avatar.url)
61
- embed.title = "Message Edited"
62
- embed.description = f"**Before:** {before.content or '*(empty message)*'}\n**After:** {after.content or '*(empty message)*'}"
63
- embed.add_field(name="Author Username", value=before.author.name, inline=True)
64
- embed.add_field(name="Channel", value=before.channel.mention, inline=True)
65
- #embed.add_field(name="Message Created On", value=before.created_at.strftime("%Y-%m-%d %H:%M:%S UTC"), inline=True)
66
- embed.add_field(name="Message Created On", value=convert_to_timezone(before.created_at, zurich_tz), inline=True)
67
- embed.add_field(name="Message ID", value=before.id, inline=True)
68
- embed.add_field(name="Message Jump URL", value=f"[Jump to message!](https://discord.com/channels/{before.guild.id}/{before.channel.id}/{before.id})", inline=True)
69
-
70
- if before.attachments:
71
- attachment_urls = "\n".join([attachment.url for attachment in before.attachments])
72
- embed.add_field(name="Attachments", value=attachment_urls, inline=False)
73
-
74
- #embed.set_footer(text=f"{datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S UTC')}")
75
- embed.set_footer(text=f"{convert_to_timezone(datetime.utcnow(), zurich_tz)}")
76
-
77
- if LOG_CHANNEL is not None:
78
- await LOG_CHANNEL.send(embed=embed)
79
- else:
80
- print("Log channel not found.")
 
 
 
81
 
82
  @bot.event
83
  async def on_message_delete(message):
 
84
  if message.author == bot.user:
85
  return
86
 
@@ -102,7 +106,13 @@ async def on_message_delete(message):
102
  #embed.set_footer(text=f"{datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S UTC')}")
103
  embed.set_footer(text=f"{convert_to_timezone(datetime.utcnow(), zurich_tz)}")
104
 
105
- await LOG_CHANNEL.send(embed=embed)
 
 
 
 
 
 
106
 
107
  # nickname stuff
108
  @bot.event
 
22
  zurich_tz = timezone("Europe/Zurich")
23
  intents = discord.Intents.all()
24
  bot = commands.Bot(command_prefix='!', intents=intents)
25
+ LOG_CHANNEL = bot.get_channel(1107006391547342910)
26
  print(f"LOG_CHANNEL: {LOG_CHANNEL}")
27
  # test = 1126516932527534111
28
  # bot-test = 1100458786826747945
 
52
 
53
  @bot.event
54
  async def on_message_edit(before, after):
55
+ try:
56
+ if before.author == bot.user:
57
+ return
58
+
59
+ if before.content != after.content:
60
+ embed = Embed(color=Color.orange())
61
+ embed.set_author(name=f"{before.author} ID: {before.author.id}", icon_url=before.author.avatar.url)
62
+ embed.title = "Message Edited"
63
+ embed.description = f"**Before:** {before.content or '*(empty message)*'}\n**After:** {after.content or '*(empty message)*'}"
64
+ embed.add_field(name="Author Username", value=before.author.name, inline=True)
65
+ embed.add_field(name="Channel", value=before.channel.mention, inline=True)
66
+ #embed.add_field(name="Message Created On", value=before.created_at.strftime("%Y-%m-%d %H:%M:%S UTC"), inline=True)
67
+ embed.add_field(name="Message Created On", value=convert_to_timezone(before.created_at, zurich_tz), inline=True)
68
+ embed.add_field(name="Message ID", value=before.id, inline=True)
69
+ embed.add_field(name="Message Jump URL", value=f"[Jump to message!](https://discord.com/channels/{before.guild.id}/{before.channel.id}/{before.id})", inline=True)
70
+
71
+ if before.attachments:
72
+ attachment_urls = "\n".join([attachment.url for attachment in before.attachments])
73
+ embed.add_field(name="Attachments", value=attachment_urls, inline=False)
74
+
75
+ #embed.set_footer(text=f"{datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S UTC')}")
76
+ embed.set_footer(text=f"{convert_to_timezone(datetime.utcnow(), zurich_tz)}")
77
+
78
+ if LOG_CHANNEL is not None:
79
+ await LOG_CHANNEL.send(embed=embed)
80
+ else:
81
+ print("Log channel not found.")
82
+ except Exception as e:
83
+ print(f"Error: {e}")
84
 
85
  @bot.event
86
  async def on_message_delete(message):
87
+ try:
88
  if message.author == bot.user:
89
  return
90
 
 
106
  #embed.set_footer(text=f"{datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S UTC')}")
107
  embed.set_footer(text=f"{convert_to_timezone(datetime.utcnow(), zurich_tz)}")
108
 
109
+ if LOG_CHANNEL is not None:
110
+ await LOG_CHANNEL.send(embed=embed)
111
+ else:
112
+ print("Log channel not found.")
113
+ except Exception as e:
114
+ print(f"Error: {e}")
115
+
116
 
117
  # nickname stuff
118
  @bot.event