lunarflu HF staff commited on
Commit
e971ea4
1 Parent(s): 2d0ceee
Files changed (1) hide show
  1. app.py +53 -41
app.py CHANGED
@@ -251,51 +251,63 @@ async def restore_exp(ctx):
251
  lvl14 = guild.get_role(1171525062201966724)
252
  lvl15 = guild.get_role(1171525098465918996)
253
 
254
- # find all members with lvl13 role
255
- members_with_role = [member.id for member in ctx.guild.members if lvl13 in member.roles]
256
- # extract user_id + xp based on level
257
- for member_id in members_with_role:
258
- member = await bot.fetch_user(member_id)
259
- xp = calculate_xp(13)
260
- level = calculate_level(xp+1)
261
-
262
- string_member_id = str(member_id)
263
- string_xp = str(xp)
264
- string_level = str(level)
265
-
266
- # get column name / data to safetycheck
267
 
 
 
 
 
 
 
 
 
 
268
 
269
- # does a record already exist?
270
- cell = worksheet.find(string_member_id)
271
- if cell is None:
272
- print(f"creating new record for {member}")
273
- # if not, create new record
274
- length = len(worksheet.col_values(1))
275
- worksheet.update(values=[[string_member_id, member.name, xp, level]], range_name=f'A{length+1}:D{length+1}')
276
- """
277
- cell = worksheet.cell(length+1,1)
278
- worksheet.update_cell(length+1, 1, string_member_id)
279
- worksheet.update_cell(length+1, 2, member.name)
280
- worksheet.update_cell(length+1, 3, string_xp)
281
- worksheet.update_cell(length+1, 4, string_level)
282
- """
283
- else:
284
- if cell:
285
- print(f"updating record for {member}")
286
- # if so, update that row...
287
- # update exp, can only be in a positive direction
288
- worksheet.update(values=[[xp, level]], range_name=f'C{cell.row}:D{cell.row}')
 
 
 
289
  """
290
- worksheet.update_cell(cell.row, cell.col+2, xp)
291
- worksheet.update_cell(cell.row, cell.col+3, level)
 
 
 
292
  """
293
-
294
- """
295
- value = cell.value
296
- row_number = cell.row
297
- column_number = cell.col
298
- """
 
 
 
 
 
 
 
 
 
 
299
 
300
 
301
 
 
251
  lvl14 = guild.get_role(1171525062201966724)
252
  lvl15 = guild.get_role(1171525098465918996)
253
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
 
255
+ level_roles = [lvl1,lvl2,lvl3,lvl4,lvl5,lvl6,lvl7,lvl8,lvl9,lvl10,lvl11,lvl12,lvl13,lvl14,lvl15]
256
+
257
+
258
+ for role in level_roles:
259
+ role_members = [member.id for member in ctx.guild.members if role in member.roles]
260
+
261
+ # role = position in level_roles + some adjustment factor
262
+ # list of people in a given role (e.g. lvl5)
263
+ print(f"role: {role} | role_members: {role_members}")
264
 
265
+ #members_with_role = [member.id for member in ctx.guild.members if lvl13 in member.roles]
266
+ # extract user_id + xp based on level
267
+ for member_id in role_members:
268
+ member = await bot.fetch_user(member_id)
269
+ #xp = calculate_xp(13)
270
+ xp = calculate_xp(role)
271
+ level = calculate_level(xp+1)
272
+ print(f"{role} {level} {xp} {member}")
273
+
274
+ string_member_id = str(member_id)
275
+ string_xp = str(xp)
276
+ string_level = str(level)
277
+
278
+ # get column name / data to safetycheck
279
+
280
+
281
+ # does a record already exist?
282
+ cell = worksheet.find(string_member_id)
283
+ if cell is None:
284
+ print(f"creating new record for {member}")
285
+ # if not, create new record
286
+ length = len(worksheet.col_values(1))
287
+ worksheet.update(values=[[string_member_id, member.name, xp, level]], range_name=f'A{length+1}:D{length+1}')
288
  """
289
+ cell = worksheet.cell(length+1,1)
290
+ worksheet.update_cell(length+1, 1, string_member_id)
291
+ worksheet.update_cell(length+1, 2, member.name)
292
+ worksheet.update_cell(length+1, 3, string_xp)
293
+ worksheet.update_cell(length+1, 4, string_level)
294
  """
295
+ else:
296
+ if cell:
297
+ print(f"updating record for {member}")
298
+ # if so, update that row...
299
+ # update exp, can only be in a positive direction
300
+ worksheet.update(values=[[xp, level]], range_name=f'C{cell.row}:D{cell.row}')
301
+ """
302
+ worksheet.update_cell(cell.row, cell.col+2, xp)
303
+ worksheet.update_cell(cell.row, cell.col+3, level)
304
+ """
305
+
306
+ """
307
+ value = cell.value
308
+ row_number = cell.row
309
+ column_number = cell.col
310
+ """
311
 
312
 
313