lunarflu HF Staff commited on
Commit
029c36b
·
1 Parent(s): 262ca60

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -12
app.py CHANGED
@@ -51,21 +51,18 @@ async def save_forum(ctx, channel_id: int):
51
  threads = channel.threads
52
 
53
 
54
-
55
- messages_data = []
 
56
  for thread in threads:
57
- async for message in thread.history(limit=None): # limit=None retrieves all messages
58
- message_data = {
59
- "content": message.content,
60
- "author": message.author.name,
61
- "timestamp": message.created_at.isoformat()
62
- }
63
- messages_data.append(message_data)
64
 
65
-
66
- print(messages_data)
67
  with open("gradio-questions.json", 'w', encoding='utf-8') as file:
68
- file.write(f"{messages_data}\n")
 
69
 
70
  await ctx.send(f"Messages from {channel.name} saved to gradio-questions.json")
71
 
 
51
  threads = channel.threads
52
 
53
 
54
+
55
+
56
+ messages = []
57
  for thread in threads:
58
+ async for message in thread.history(limit=None):
59
+ messages.append(message)
60
+
61
+ print(messages) # debug
 
 
 
62
 
 
 
63
  with open("gradio-questions.json", 'w', encoding='utf-8') as file:
64
+ for message in messages:
65
+ file.write(f"{message.content}\n")
66
 
67
  await ctx.send(f"Messages from {channel.name} saved to gradio-questions.json")
68