lunarflu HF staff commited on
Commit
52ccbe4
1 Parent(s): 30d9ea2

Synced repo using 'sync_with_huggingface' Github Action

Browse files
Files changed (1) hide show
  1. app.py +19 -8
app.py CHANGED
@@ -140,15 +140,26 @@ def calculate_level(xp):
140
  async def level(ctx):
141
  if ctx.author.id == 811235357663297546:
142
 
143
- for author_id_str, xp_value in xp_data.items():
144
- try:
145
- current_level = calculate_level(xp_value)
146
- author_id = int(author_id_str)
147
- user = bot.get_user(author_id)
148
- print(f"user: {user} | xp: {xp_value} | level: {current_level}")
 
 
 
149
 
150
- except Exception as e:
151
- print(f"Error for user {author_id}: {e}")
 
 
 
 
 
 
 
 
152
  """
153
  if author_id in xp_data:
154
  xp = xp_data[author_id]
 
140
  async def level(ctx):
141
  if ctx.author.id == 811235357663297546:
142
 
143
+ try:
144
+ user_data = []
145
+
146
+ for author_id_str, xp_value in xp_data.items():
147
+ try:
148
+ current_level = calculate_level(xp_value)
149
+ author_id = int(author_id_str)
150
+ user = bot.get_user(author_id)
151
+ user_data.append((user, xp_value, current_level))
152
 
153
+ except Exception as e:
154
+ print(f"Error for user {author_id}: {e}")
155
+
156
+ sorted_user_data = sorted(user_data, key=lambda x: x[2], reverse=True)
157
+
158
+ for user, xp, level in sorted_user_data:
159
+ print(f"user: {user} | xp: {xp} | level: {level}")
160
+
161
+ except Exception as e:
162
+ print(f"Error: {e}")
163
  """
164
  if author_id in xp_data:
165
  xp = xp_data[author_id]