lunarflu HF staff commited on
Commit
680ad08
1 Parent(s): 41f6d43

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py CHANGED
@@ -249,6 +249,24 @@ async def top_gradio(ctx, channel_id):
249
  top_list = "\n".join([f"{member.name}: {count}" for member, count in sorted_users[:50]])
250
  print(f"Message count per user in the channel:\n{top_list}")
251
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
252
 
253
  """"""
254
  DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
 
249
  top_list = "\n".join([f"{member.name}: {count}" for member, count in sorted_users[:50]])
250
  print(f"Message count per user in the channel:\n{top_list}")
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]])
268
+ print(f"Message count per user in the channel:\n{top_list}")
269
+
270
 
271
  """"""
272
  DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)