lunarflu HF staff commited on
Commit
9b2d35f
1 Parent(s): d8acdb0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -251,21 +251,23 @@ async def top_gradio(ctx, channel_id):
251
 
252
 
253
  @bot.command()
254
- async def top_gradio_threads(ctx, parent_id):
255
  if ctx.author.id == 811235357663297546:
256
  message_counts = {}
257
 
258
- all_channels = await ctx.guild.fetch_channels()
259
- print(all_channels)
260
- threads = [channel for channel in all_channels if isinstance(channel, discord.Thread)]
261
  print(threads)
262
- good_threads = [thread for thread in threads if thread.parent_id==parent_id]
263
- print(good_threads)
264
-
265
- for thread in good_threads:
266
  print(f"Thread Name: {thread.name}, Thread ID: {thread.id}, Parent ID: {thread.parent_id}")
267
  async for message in thread.history(limit=None):
268
  message_counts[message.author] = message_counts.get(message.author, 0) + 1
 
 
 
 
 
269
 
270
  sorted_users = sorted(message_counts.items(), key=lambda x: x[1], reverse=True)
271
  top_list = "\n".join([f"{member.name}: {count}" for member, count in sorted_users[:50]])
 
251
 
252
 
253
  @bot.command()
254
+ async def top_gradio_threads(ctx, channel_id):
255
  if ctx.author.id == 811235357663297546:
256
  message_counts = {}
257
 
258
+ channel = await bot.get_channel(channel_id)
259
+ print(channel)
260
+ threads = channel.threads
261
  print(threads)
262
+ for thread in threads:
 
 
 
263
  print(f"Thread Name: {thread.name}, Thread ID: {thread.id}, Parent ID: {thread.parent_id}")
264
  async for message in thread.history(limit=None):
265
  message_counts[message.author] = message_counts.get(message.author, 0) + 1
266
+
267
+ async for thread in channel.archived_threads(limit=None):
268
+ print(f"ARCHIVED Thread Name: {thread.name}, ARCHIVED Thread ID: {thread.id}, Parent ID: {thread.parent_id}")
269
+ message_counts[message.author] = message_counts.get(message.author, 0) + 1
270
+
271
 
272
  sorted_users = sorted(message_counts.items(), key=lambda x: x[1], reverse=True)
273
  top_list = "\n".join([f"{member.name}: {count}" for member, count in sorted_users[:50]])