Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
async def top_gradio(ctx, channel_id):
Browse files
app.py
CHANGED
@@ -78,6 +78,7 @@ async def level(ctx):
|
|
78 |
await ctx.send('You have not earned any XP yet.')
|
79 |
# show top users by level / exp
|
80 |
|
|
|
81 |
@bot.command()
|
82 |
async def count(ctx):
|
83 |
"""Count total messages per user in all channels."""
|
@@ -159,7 +160,6 @@ async def count_messages30(ctx):
|
|
159 |
print(f'Total messages between {start_date} and {end_date}: {message_count}')
|
160 |
|
161 |
|
162 |
-
|
163 |
@bot.command()
|
164 |
async def count_messages60(ctx):
|
165 |
if ctx.author.id == 811235357663297546:
|
@@ -232,6 +232,23 @@ async def count_forum_threads(ctx, time: int):
|
|
232 |
|
233 |
print(f'Total forum_thread_messages between {start_date} and {end_date}: {forum_thread_message_count}')
|
234 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
|
236 |
""""""
|
237 |
DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
|
|
|
78 |
await ctx.send('You have not earned any XP yet.')
|
79 |
# show top users by level / exp
|
80 |
|
81 |
+
|
82 |
@bot.command()
|
83 |
async def count(ctx):
|
84 |
"""Count total messages per user in all channels."""
|
|
|
160 |
print(f'Total messages between {start_date} and {end_date}: {message_count}')
|
161 |
|
162 |
|
|
|
163 |
@bot.command()
|
164 |
async def count_messages60(ctx):
|
165 |
if ctx.author.id == 811235357663297546:
|
|
|
232 |
|
233 |
print(f'Total forum_thread_messages between {start_date} and {end_date}: {forum_thread_message_count}')
|
234 |
|
235 |
+
|
236 |
+
@bot.command()
|
237 |
+
async def top_gradio(ctx, channel_id):
|
238 |
+
if ctx.author.id == 811235357663297546:
|
239 |
+
message_counts = {}
|
240 |
+
channel = bot.get_channel(channel_id)
|
241 |
+
|
242 |
+
try:
|
243 |
+
async for message in channel.history(limit=None):
|
244 |
+
message_counts[message.author] = message_counts.get(message.author, 0) + 1
|
245 |
+
except discord.Forbidden:
|
246 |
+
print(f"Missing access to read messages in {channel.name}")
|
247 |
+
|
248 |
+
sorted_users = sorted(message_counts.items(), key=lambda x: x[1], reverse=True)
|
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)
|