lunarflu HF staff commited on
Commit
acd0e33
1 Parent(s): 6089095

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -9
app.py CHANGED
@@ -230,23 +230,26 @@ async def on_reaction_add(reaction, user):
230
  @bot.command(name='update_leaderboard')
231
  async def update_leaderboard(ctx):
232
  worksheet = gspread_bot.open("levelbot").sheet1
233
- levels_list = worksheet.col_values(4) # level
234
- names_list = worksheet.col_values(2) # discord usernames
235
 
236
 
237
  channel = bot.get_channel(1197143964994773023)
238
  message = await channel.fetch_message(1197148293164187678)
239
 
240
- # levels first
241
- header = levels_list[0]
242
- levels_list = levels_list[1:]
243
- print(levels_list)
244
 
245
  levels_list = list(map(int, levels_list))
246
- sorted_levels = sorted(enumerate(levels_list, start=1), key=lambda x: x[1], reverse=True)
247
- top_10_levels = sorted_levels[:10]
248
- print(top_10_levels)
249
 
 
 
 
 
 
 
250
 
251
  new_leaderboard_data = [("User 1", 120), ("User 2", 90), ("User 3", 70)]
252
  new_table = tabulate(new_leaderboard_data, headers=["User", "Score"], tablefmt="plain")
@@ -278,6 +281,9 @@ async def send_message(ctx):
278
  # fix sheet if necessary
279
 
280
 
 
 
 
281
 
282
  """"""
283
  DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
 
230
  @bot.command(name='update_leaderboard')
231
  async def update_leaderboard(ctx):
232
  worksheet = gspread_bot.open("levelbot").sheet1
233
+ levels_list = worksheet.col_values(4)[1:]
234
+ names_list = worksheet.col_values(2)[1:]
235
 
236
 
237
  channel = bot.get_channel(1197143964994773023)
238
  message = await channel.fetch_message(1197148293164187678)
239
 
240
+
 
 
 
241
 
242
  levels_list = list(map(int, levels_list))
243
+ data_pairs = list(zip(names_list, levels_list))
244
+ sorted_data_pairs = sorted(data_pairs, key=lambda x: x[1], reverse=True)
245
+ top_10_data_pairs = sorted_data_pairs[:10]
246
 
247
+ for name, level in top_10_data_pairs:
248
+ print(f"Name: {name}, Level: {level}")
249
+
250
+ # get position, then find that value in names_list
251
+
252
+ # put into message / leaderboard
253
 
254
  new_leaderboard_data = [("User 1", 120), ("User 2", 90), ("User 3", 70)]
255
  new_table = tabulate(new_leaderboard_data, headers=["User", "Score"], tablefmt="plain")
 
281
  # fix sheet if necessary
282
 
283
 
284
+ # might need cell location data to pull both level and username at same time
285
+
286
+
287
 
288
  """"""
289
  DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)