Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -70,30 +70,22 @@ async def level(ctx):
|
|
70 |
|
71 |
|
72 |
@bot.command()
|
73 |
-
async def
|
74 |
-
"""
|
75 |
-
|
76 |
-
|
|
|
|
|
|
|
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
|
84 |
-
await ctx.send(f"
|
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 |
|
|
|
70 |
|
71 |
|
72 |
@bot.command()
|
73 |
+
async def count_messages(ctx, channel_name: str):
|
74 |
+
"""Count messages per user in a specific channel."""
|
75 |
+
channel = discord.utils.get(ctx.guild.text_channels, name=channel_name)
|
76 |
+
|
77 |
+
if not channel:
|
78 |
+
await ctx.send("Channel not found.")
|
79 |
+
return
|
80 |
|
81 |
+
message_counts = {}
|
82 |
async for message in channel.history(limit=None):
|
83 |
if not message.author.bot:
|
84 |
message_counts[message.author] = message_counts.get(message.author, 0) + 1
|
85 |
|
86 |
sorted_users = sorted(message_counts.items(), key=lambda x: x[1], reverse=True)
|
87 |
+
top_list = "\n".join([f"{member.name}: {count}" for member, count in sorted_users])
|
88 |
+
await ctx.send(f"Message count per user in #{channel_name}:\n{top_list}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
|
90 |
|
91 |
|