lunarflu HF Staff commited on
Commit
a3b8700
·
verified ·
1 Parent(s): 8d44e58

remove search command; append discord_id to message content for easy searching

Browse files
Files changed (1) hide show
  1. app.py +12 -47
app.py CHANGED
@@ -39,51 +39,7 @@ message_cache = {}
39
 
40
 
41
 
42
- LOG_CHANNEL_IDS = {
43
- "posted": 1380960802990854204,
44
- "edited": 1380960825795411978,
45
- "deleted": 1380960864990924941,
46
- }
47
-
48
-
49
- # test
50
- @bot.command()
51
- async def search(ctx, target_id: str):
52
- collected = []
53
-
54
- for log_type, channel_id in LOG_CHANNEL_IDS.items():
55
- channel = bot.get_channel(channel_id)
56
- if not channel:
57
- await ctx.send(f"Could not access log channel: {log_type}")
58
- continue
59
-
60
- async for message in channel.history(limit=1000): # adjust limit as needed
61
- if not message.embeds:
62
- continue
63
-
64
- embed = message.embeds[0]
65
- for field in embed.fields:
66
- if field.name.startswith("ID:") and target_id in field.value:
67
- entry = {
68
- "log_type": log_type,
69
- "timestamp": str(embed.timestamp),
70
- "author": embed.author.name,
71
- "description": embed.description,
72
- "fields": {f.name: f.value for f in embed.fields},
73
- "jump_url": embed.url if embed.url else "N/A",
74
- }
75
- collected.append(entry)
76
- break
77
-
78
- if not collected:
79
- await ctx.send(f"No logs found for ID `{target_id}`.")
80
- return
81
-
82
- # Save results to a JSON file in-memory
83
- json_data = json.dumps(collected, indent=2)
84
- file = discord.File(io.BytesIO(json_data.encode()), filename=f"{target_id}_logs.json")
85
 
86
- await ctx.send(f"Found {len(collected)} logs for ID `{target_id}`:", file=file)
87
 
88
 
89
  # twitter
@@ -126,7 +82,9 @@ async def on_message(message):
126
  embed = Embed(color=Color.blue())
127
  embed.set_author(name=f"{message.author} ID: {message.author.id}", icon_url=message.author.avatar.url if message.author.avatar else bot.user.avatar.url)
128
  embed.title = f"Message Posted"
129
- embed.description = message.content or "*(empty message)*"
 
 
130
  embed.add_field(name="Author Username", value=message.author.name, inline=True)
131
  embed.add_field(name="Channel", value=message.channel.mention, inline=True)
132
  embed.add_field(name="Message Created On", value=convert_to_timezone(message.created_at, zurich_tz), inline=True)
@@ -271,7 +229,12 @@ async def on_message_edit(before, after):
271
  embed = Embed(color=Color.orange())
272
  embed.set_author(name=f"{before.author} ID: {before.author.id}", icon_url=before.author.avatar.url if before.author.avatar else bot.user.avatar.url)
273
  embed.title = "Message Edited"
274
- embed.description = f"**Before:** {before.content or '*(empty message)*'}\n**After:** {after.content or '*(empty message)*'}"
 
 
 
 
 
275
  embed.add_field(name="Author Username", value=before.author.name, inline=True)
276
  embed.add_field(name="Channel", value=before.channel.mention, inline=True)
277
  #embed.add_field(name="Message Created On", value=before.created_at.strftime("%Y-%m-%d %H:%M:%S UTC"), inline=True)
@@ -303,7 +266,9 @@ async def on_raw_message_delete(payload):
303
  embed = Embed(color=Color.red())
304
  embed.set_author(name=f"{message.author} ID: {message.author.id}", icon_url=message.author.avatar.url if message.author.avatar else bot.user.avatar.url)
305
  embed.title = "Message Deleted"
306
- embed.description = message.content or "*(empty message)*"
 
 
307
  embed.add_field(name="Author Username", value=message.author.name, inline=True)
308
  embed.add_field(name="Channel", value=message.channel.mention, inline=True)
309
  #embed.add_field(name="Message Created On", value=message.created_at.strftime("%Y-%m-%d %H:%M:%S UTC"), inline=True)
 
39
 
40
 
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
 
43
 
44
 
45
  # twitter
 
82
  embed = Embed(color=Color.blue())
83
  embed.set_author(name=f"{message.author} ID: {message.author.id}", icon_url=message.author.avatar.url if message.author.avatar else bot.user.avatar.url)
84
  embed.title = f"Message Posted"
85
+ #embed.description = message.content or "*(empty message)*"
86
+ embed.description = f"ID: {message.author.id}\n{message.content or '*(empty message)*'}"
87
+
88
  embed.add_field(name="Author Username", value=message.author.name, inline=True)
89
  embed.add_field(name="Channel", value=message.channel.mention, inline=True)
90
  embed.add_field(name="Message Created On", value=convert_to_timezone(message.created_at, zurich_tz), inline=True)
 
229
  embed = Embed(color=Color.orange())
230
  embed.set_author(name=f"{before.author} ID: {before.author.id}", icon_url=before.author.avatar.url if before.author.avatar else bot.user.avatar.url)
231
  embed.title = "Message Edited"
232
+ #embed.description = f"**Before:** {before.content or '*(empty message)*'}\n**After:** {after.content or '*(empty message)*'}"
233
+ embed.description = (
234
+ f"ID: {before.author.id}\n"
235
+ f"**Before:** {before.content or '*(empty message)*'}\n"
236
+ f"**After:** {after.content or '*(empty message)*'}"
237
+ )
238
  embed.add_field(name="Author Username", value=before.author.name, inline=True)
239
  embed.add_field(name="Channel", value=before.channel.mention, inline=True)
240
  #embed.add_field(name="Message Created On", value=before.created_at.strftime("%Y-%m-%d %H:%M:%S UTC"), inline=True)
 
266
  embed = Embed(color=Color.red())
267
  embed.set_author(name=f"{message.author} ID: {message.author.id}", icon_url=message.author.avatar.url if message.author.avatar else bot.user.avatar.url)
268
  embed.title = "Message Deleted"
269
+ #embed.description = message.content or "*(empty message)*"
270
+ embed.description = f"ID: {message.author.id}\n{message.content or '*(empty message)*'}"
271
+
272
  embed.add_field(name="Author Username", value=message.author.name, inline=True)
273
  embed.add_field(name="Channel", value=message.channel.mention, inline=True)
274
  #embed.add_field(name="Message Created On", value=message.created_at.strftime("%Y-%m-%d %H:%M:%S UTC"), inline=True)