Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
safetychecks (only I can use commands for now)
Browse files
app.py
CHANGED
|
@@ -60,31 +60,33 @@ def calculate_level(xp):
|
|
| 60 |
|
| 61 |
@bot.command()
|
| 62 |
async def level(ctx):
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
|
|
|
| 70 |
|
| 71 |
|
| 72 |
@bot.command()
|
| 73 |
async def count(ctx):
|
| 74 |
"""Count total messages per user in all channels."""
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
|
|
|
| 88 |
|
| 89 |
|
| 90 |
""""""
|
|
|
|
| 60 |
|
| 61 |
@bot.command()
|
| 62 |
async def level(ctx):
|
| 63 |
+
if ctx.author.id == 811235357663297546:
|
| 64 |
+
author_id = str(ctx.author.id)
|
| 65 |
+
if author_id in xp_data:
|
| 66 |
+
xp = xp_data[author_id]
|
| 67 |
+
level = calculate_level(xp)
|
| 68 |
+
await ctx.send(f'You are at level {level} with {xp} XP.')
|
| 69 |
+
else:
|
| 70 |
+
await ctx.send('You have not earned any XP yet.')
|
| 71 |
|
| 72 |
|
| 73 |
@bot.command()
|
| 74 |
async def count(ctx):
|
| 75 |
"""Count total messages per user in all channels."""
|
| 76 |
+
if ctx.author.id == 811235357663297546:
|
| 77 |
+
message_counts = {}
|
| 78 |
+
|
| 79 |
+
for channel in ctx.guild.text_channels:
|
| 80 |
+
try:
|
| 81 |
+
async for message in channel.history(limit=None):
|
| 82 |
+
message_counts[message.author] = message_counts.get(message.author, 0) + 1
|
| 83 |
+
except discord.Forbidden:
|
| 84 |
+
# Handle the Forbidden error
|
| 85 |
+
await ctx.send(f"Missing access to read messages in {channel.name}")
|
| 86 |
+
|
| 87 |
+
sorted_users = sorted(message_counts.items(), key=lambda x: x[1], reverse=True)
|
| 88 |
+
top_list = "\n".join([f"{member.name}: {count}" for member, count in sorted_users])
|
| 89 |
+
await ctx.send(f"Message count per user in all text channels:\n{top_list}")
|
| 90 |
|
| 91 |
|
| 92 |
""""""
|