Spaces:
Running on CPU Upgrade

lunarflu HF staff commited on
Commit
03aa0fc
·
verified ·
1 Parent(s): 5ac73d7

fixing some logic for levels

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -229,9 +229,8 @@ async def add_exp(member_id):
229
 
230
 
231
  # level up
232
- current_level = calculate_level(new_xp)
233
- # increment the old level value (better to replace outright)
234
- global_df.loc[index, 'discord_level'] = current_level # do not change column name
235
 
236
  print(f"Current_level for {member}: {current_level}")
237
  if current_level >= 2 and current_level <=30:
@@ -240,18 +239,18 @@ async def add_exp(member_id):
240
 
241
  # temporary fix: remove ~100 exp when not verified, send embed on "levelup" prompting to verify
242
  # if level 3 -> then send embed, remove some exp
243
- if current_level >= 3:
244
- verified_role = guild.get_role(900063512829755413)
245
  if verified_role not in member.roles:
246
 
247
- # claim exp
248
- claim_exp = new_xp - 30
 
249
 
250
  # send embed
251
  embed = Embed(color=Color.red())
252
  embed.set_author(name=f"{member}", icon_url=member.avatar.url if member.avatar else bot.user.avatar.url)
253
  embed.title = f"⚠️Your account is not Verified! Unable to level up `{current_level-1}` -> `{current_level}` ❌"
254
- msg = f'🤗 Hey {member}! You can continue leveling up in the Hugging Face Discord server by Verifying your account, and claim `{claim_exp}` plus `100` bonus exp points!'
255
  embed.description = f"{msg}"
256
  verification_link = "https://discord.com/channels/879548962464493619/900125909984624713"
257
  embed.add_field(name="Verify Here:", value=verification_link, inline=True)
@@ -269,7 +268,9 @@ async def add_exp(member_id):
269
 
270
 
271
 
272
-
 
 
273
 
274
  await member.add_roles(current_role)
275
  print(f"Level Up! Gave {member} {current_role}")
 
229
 
230
 
231
  # level up
232
+ current_level = calculate_level(new_xp)
233
+ verified_role = guild.get_role(900063512829755413)
 
234
 
235
  print(f"Current_level for {member}: {current_level}")
236
  if current_level >= 2 and current_level <=30:
 
239
 
240
  # temporary fix: remove ~100 exp when not verified, send embed on "levelup" prompting to verify
241
  # if level 3 -> then send embed, remove some exp
242
+ if current_level >= 3: # could change to 4 maybe
 
243
  if verified_role not in member.roles:
244
 
245
+ # claim exp (-30 for level 3, but +100 as bonus exp. This scales infinitely until the member verifies,
246
+ # so they can continue earning exp, it just won't translate to levels and the leaderboard.
247
+ claim_exp = new_xp + 70
248
 
249
  # send embed
250
  embed = Embed(color=Color.red())
251
  embed.set_author(name=f"{member}", icon_url=member.avatar.url if member.avatar else bot.user.avatar.url)
252
  embed.title = f"⚠️Your account is not Verified! Unable to level up `{current_level-1}` -> `{current_level}` ❌"
253
+ msg = f'🤗 Hey {member}! You can continue leveling up in the Hugging Face Discord server by Verifying your account, and claim `{claim_exp}` bonus exp points!'
254
  embed.description = f"{msg}"
255
  verification_link = "https://discord.com/channels/879548962464493619/900125909984624713"
256
  embed.add_field(name="Verify Here:", value=verification_link, inline=True)
 
268
 
269
 
270
 
271
+ # increment the old level value (better to replace outright)
272
+ # only increment level column if you are lvl2 or 3+ with verified role
273
+ global_df.loc[index, 'discord_level'] = current_level # do not change column name
274
 
275
  await member.add_roles(current_role)
276
  print(f"Level Up! Gave {member} {current_role}")