Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Synced repo using 'sync_with_huggingface' Github Action
Browse files
app.py
CHANGED
@@ -27,8 +27,9 @@ async def on_ready():
|
|
27 |
print(f"XP_PER_MESSAGE: {XP_PER_MESSAGE}")
|
28 |
global xp_data
|
29 |
xp_data = load_xp_data()
|
30 |
-
print('XP data loaded:', xp_data)
|
31 |
-
|
|
|
32 |
"""
|
33 |
try:
|
34 |
with open('xp_data.json', 'r') as f:
|
@@ -61,6 +62,7 @@ async def on_message(message):
|
|
61 |
xp_data.setdefault(author_id, 0) # default if it doesn't already exist
|
62 |
|
63 |
xp_data[author_id] += XP_PER_MESSAGE
|
|
|
64 |
#print(f"xp_data: {xp_data}")
|
65 |
save_xp_data()
|
66 |
|
@@ -137,14 +139,25 @@ def calculate_level(xp):
|
|
137 |
@bot.command()
|
138 |
async def level(ctx):
|
139 |
if ctx.author.id == 811235357663297546:
|
140 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
if author_id in xp_data:
|
142 |
xp = xp_data[author_id]
|
143 |
level = calculate_level(xp)
|
144 |
await ctx.send(f'You are at level {level} with {xp} XP.')
|
145 |
else:
|
146 |
await ctx.send('You have not earned any XP yet.')
|
147 |
-
# show top users by level / exp
|
|
|
|
|
148 |
|
149 |
|
150 |
@bot.command()
|
|
|
27 |
print(f"XP_PER_MESSAGE: {XP_PER_MESSAGE}")
|
28 |
global xp_data
|
29 |
xp_data = load_xp_data()
|
30 |
+
#print('XP data loaded:', xp_data)
|
31 |
+
print('XP data loaded')
|
32 |
+
|
33 |
"""
|
34 |
try:
|
35 |
with open('xp_data.json', 'r') as f:
|
|
|
62 |
xp_data.setdefault(author_id, 0) # default if it doesn't already exist
|
63 |
|
64 |
xp_data[author_id] += XP_PER_MESSAGE
|
65 |
+
print(f"{message.author} = {xp_data[author.id]}")
|
66 |
#print(f"xp_data: {xp_data}")
|
67 |
save_xp_data()
|
68 |
|
|
|
139 |
@bot.command()
|
140 |
async def level(ctx):
|
141 |
if ctx.author.id == 811235357663297546:
|
142 |
+
|
143 |
+
for author_id, xp_value in xp_data.items():
|
144 |
+
try:
|
145 |
+
current_level = calculate_level(xp_value)
|
146 |
+
user = bot.get_user(author_id)
|
147 |
+
print(f"user: {user} | xp: {xp_value} | level: {current_level}")
|
148 |
+
|
149 |
+
except Exception as e:
|
150 |
+
print(f"Error for user {author_id}: {e}")
|
151 |
+
"""
|
152 |
if author_id in xp_data:
|
153 |
xp = xp_data[author_id]
|
154 |
level = calculate_level(xp)
|
155 |
await ctx.send(f'You are at level {level} with {xp} XP.')
|
156 |
else:
|
157 |
await ctx.send('You have not earned any XP yet.')
|
158 |
+
# show top users by level / exp
|
159 |
+
"""
|
160 |
+
|
161 |
|
162 |
|
163 |
@bot.command()
|