Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
backup_xp
Browse files
app.py
CHANGED
|
@@ -36,6 +36,8 @@ def save_xp_data():
|
|
| 36 |
json.dump(xp_data, f)
|
| 37 |
|
| 38 |
|
|
|
|
|
|
|
| 39 |
@bot.event
|
| 40 |
async def on_message(message):
|
| 41 |
try:
|
|
@@ -52,10 +54,10 @@ async def on_message(message):
|
|
| 52 |
except Exception as e:
|
| 53 |
print(f"Error: {e}")
|
| 54 |
|
| 55 |
-
|
| 56 |
# Calculate the level based on XP
|
| 57 |
def calculate_level(xp):
|
| 58 |
-
return int(xp ** 0.
|
| 59 |
|
| 60 |
|
| 61 |
@bot.command()
|
|
@@ -69,6 +71,31 @@ async def level(ctx):
|
|
| 69 |
await ctx.send('You have not earned any XP yet.')
|
| 70 |
|
| 71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
@bot.command()
|
| 73 |
async def count_messages(ctx, channel_name: str):
|
| 74 |
"""Count messages per user in a specific channel."""
|
|
|
|
| 36 |
json.dump(xp_data, f)
|
| 37 |
|
| 38 |
|
| 39 |
+
|
| 40 |
+
|
| 41 |
@bot.event
|
| 42 |
async def on_message(message):
|
| 43 |
try:
|
|
|
|
| 54 |
except Exception as e:
|
| 55 |
print(f"Error: {e}")
|
| 56 |
|
| 57 |
+
|
| 58 |
# Calculate the level based on XP
|
| 59 |
def calculate_level(xp):
|
| 60 |
+
return int(xp ** (1.0 / 3.0))
|
| 61 |
|
| 62 |
|
| 63 |
@bot.command()
|
|
|
|
| 71 |
await ctx.send('You have not earned any XP yet.')
|
| 72 |
|
| 73 |
|
| 74 |
+
@bot.command()
|
| 75 |
+
async def backup_xp(ctx):
|
| 76 |
+
save_xp_data(xp_data)
|
| 77 |
+
with open('xp_data.json', 'rb') as f:
|
| 78 |
+
await ctx.send(file=discord.File(f, 'xp_data.json'))
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
|
| 99 |
@bot.command()
|
| 100 |
async def count_messages(ctx, channel_name: str):
|
| 101 |
"""Count messages per user in a specific channel."""
|