Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -73,13 +73,31 @@ async def level(ctx):
|
|
73 |
async def top_users(ctx, limit: int = 10):
|
74 |
"""Get the top users with the highest message counts."""
|
75 |
message_counts = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
for member in ctx.guild.members:
|
77 |
#if not member.bot:
|
78 |
message_counts[member] = sum(1 for _ in await ctx.history(user=member).flatten())
|
79 |
|
80 |
sorted_users = sorted(message_counts.items(), key=lambda x: x[1], reverse=True)
|
81 |
top_list = "\n".join([f"{member.name}: {count}" for member, count in sorted_users[:limit]])
|
82 |
-
await ctx.send(f"Top {limit} users by message count:\n{top_list}")
|
|
|
|
|
|
|
|
|
|
|
83 |
|
84 |
|
85 |
|
|
|
73 |
async def top_users(ctx, limit: int = 10):
|
74 |
"""Get the top users with the highest message counts."""
|
75 |
message_counts = {}
|
76 |
+
channel = discord.utils.get(ctx.guild.text_channels, name="general") # Replace with your channel name
|
77 |
+
|
78 |
+
async for message in channel.history(limit=None):
|
79 |
+
if not message.author.bot:
|
80 |
+
message_counts[message.author] = message_counts.get(message.author, 0) + 1
|
81 |
+
|
82 |
+
sorted_users = sorted(message_counts.items(), key=lambda x: x[1], reverse=True)
|
83 |
+
top_list = "\n".join([f"{member.name}: {count}" for member, count in sorted_users[:limit]])
|
84 |
+
await ctx.send(f"Top {limit} users by message count:\n{top_list}")
|
85 |
+
|
86 |
+
|
87 |
+
|
88 |
+
"""
|
89 |
for member in ctx.guild.members:
|
90 |
#if not member.bot:
|
91 |
message_counts[member] = sum(1 for _ in await ctx.history(user=member).flatten())
|
92 |
|
93 |
sorted_users = sorted(message_counts.items(), key=lambda x: x[1], reverse=True)
|
94 |
top_list = "\n".join([f"{member.name}: {count}" for member, count in sorted_users[:limit]])
|
95 |
+
await ctx.send(f"Top {limit} users by message count:\n{top_list}")
|
96 |
+
"""
|
97 |
+
|
98 |
+
|
99 |
+
|
100 |
+
|
101 |
|
102 |
|
103 |
|