lunarflu HF staff commited on
Commit
56cc113
1 Parent(s): 680ad08

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -251,17 +251,17 @@ async def top_gradio(ctx, channel_id):
251
 
252
 
253
  @bot.command()
254
- async def top_gradio_threads(ctx, channel_id):
255
  if ctx.author.id == 811235357663297546:
256
  message_counts = {}
257
- try:
258
- channel = await bot.fetch_channel(channel_id)
259
- threads = await channel.fetch_threads(limit=None)
260
- for thread in threads:
261
- async for message in thread.history(limit=None):
262
- message_counts[message.author] = message_counts.get(message.author, 0) + 1
263
- except discord.Forbidden:
264
- print(f"Missing access to read messages in {channel.name}")
265
 
266
  sorted_users = sorted(message_counts.items(), key=lambda x: x[1], reverse=True)
267
  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, parent_id):
255
  if ctx.author.id == 811235357663297546:
256
  message_counts = {}
257
+
258
+ all_channels = await guild.fetch_channels()
259
+ filtered_threads = [channel for channel in all_channels if isinstance(channel, discord.Thread) and channel.parent_id == parent_id]
260
+
261
+ for thread in filtered_threads:
262
+ print(f"Thread Name: {thread.name}, Thread ID: {thread.id}, Parent ID: {thread.parent_id}")
263
+ async for message in thread.history(limit=None):
264
+ message_counts[message.author] = message_counts.get(message.author, 0) + 1
265
 
266
  sorted_users = sorted(message_counts.items(), key=lambda x: x[1], reverse=True)
267
  top_list = "\n".join([f"{member.name}: {count}" for member, count in sorted_users[:50]])