Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -253,7 +253,8 @@ async def restore_exp(ctx):
|
|
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]
|
@@ -265,6 +266,10 @@ async def restore_exp(ctx):
|
|
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 |
position = level_roles.index(role) + 1
|
@@ -280,29 +285,38 @@ async def restore_exp(ctx):
|
|
280 |
|
281 |
|
282 |
# does a record already exist?
|
283 |
-
cell = worksheet.find(string_member_id)
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
|
|
|
|
|
|
|
|
|
|
296 |
else:
|
297 |
if cell:
|
|
|
|
|
298 |
print(f"updating record for {member}")
|
299 |
# if so, update that row...
|
300 |
# update exp, can only be in a positive direction
|
301 |
worksheet.update(values=[[xp, level]], range_name=f'C{cell.row}:D{cell.row}')
|
302 |
"""
|
303 |
-
worksheet.update_cell(cell.row, cell.col+2, xp)
|
304 |
-
worksheet.update_cell(cell.row, cell.col+3, level)
|
305 |
-
"""
|
|
|
|
|
306 |
|
307 |
"""
|
308 |
value = cell.value
|
|
|
253 |
|
254 |
|
255 |
level_roles = [lvl1,lvl2,lvl3,lvl4,lvl5,lvl6,lvl7,lvl8,lvl9,lvl10,lvl11,lvl12,lvl13,lvl14,lvl15]
|
256 |
+
|
257 |
+
member_id_column_values = worksheet.col_values(1)
|
258 |
|
259 |
for role in level_roles:
|
260 |
role_members = [member.id for member in ctx.guild.members if role in member.roles]
|
|
|
266 |
#members_with_role = [member.id for member in ctx.guild.members if lvl13 in member.roles]
|
267 |
# extract user_id + xp based on level
|
268 |
for member_id in role_members:
|
269 |
+
|
270 |
+
if member_id in member_id_column_values:
|
271 |
+
continue
|
272 |
+
|
273 |
member = await bot.fetch_user(member_id)
|
274 |
#xp = calculate_xp(13)
|
275 |
position = level_roles.index(role) + 1
|
|
|
285 |
|
286 |
|
287 |
# does a record already exist?
|
288 |
+
#cell = worksheet.find(string_member_id)
|
289 |
+
|
290 |
+
|
291 |
+
|
292 |
+
#if cell is None:
|
293 |
+
print(f"creating new record for {member}")
|
294 |
+
# if not, create new record
|
295 |
+
length = len(worksheet.col_values(1))
|
296 |
+
worksheet.update(values=[[string_member_id, member.name, xp, level]], range_name=f'A{length+1}:D{length+1}')
|
297 |
+
"""
|
298 |
+
cell = worksheet.cell(length+1,1)
|
299 |
+
worksheet.update_cell(length+1, 1, string_member_id)
|
300 |
+
worksheet.update_cell(length+1, 2, member.name)
|
301 |
+
worksheet.update_cell(length+1, 3, string_xp)
|
302 |
+
worksheet.update_cell(length+1, 4, string_level)
|
303 |
+
"""
|
304 |
+
|
305 |
+
"""
|
306 |
else:
|
307 |
if cell:
|
308 |
+
continue
|
309 |
+
|
310 |
print(f"updating record for {member}")
|
311 |
# if so, update that row...
|
312 |
# update exp, can only be in a positive direction
|
313 |
worksheet.update(values=[[xp, level]], range_name=f'C{cell.row}:D{cell.row}')
|
314 |
"""
|
315 |
+
#worksheet.update_cell(cell.row, cell.col+2, xp)
|
316 |
+
#worksheet.update_cell(cell.row, cell.col+3, level)
|
317 |
+
"""
|
318 |
+
"""
|
319 |
+
|
320 |
|
321 |
"""
|
322 |
value = cell.value
|