Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
int to string
Browse files
app.py
CHANGED
@@ -237,16 +237,18 @@ async def add_exp(member_id):
|
|
237 |
# increment the old experience value (better not to replace outright)
|
238 |
old_xp = global_df.loc[index, 'discord_exp']
|
239 |
# remove L (write, so we replace)
|
|
|
240 |
if old_xp.startswith("L") and old_xp.endswith("L"):
|
241 |
old_xp = old_xp[1:-1]
|
242 |
# str -> int temporarily
|
243 |
new_xp = int(old_xp) + XP_PER_MESSAGE
|
244 |
# check + convert back to string + google sheet proofing
|
245 |
-
|
|
|
246 |
new_xp = f"L" + str(new_xp) + f"L"
|
247 |
|
248 |
# add back to dataframe in memory after checking redundantly;
|
249 |
-
if new_xp
|
250 |
global_df.loc[index, 'discord_exp'] = new_xp # do not change column name
|
251 |
print(f"Record for {member} updated from {old_xp} to {global_df.loc[index, 'discord_exp']} (+{XP_PER_MESSAGE}) ")
|
252 |
|
@@ -354,7 +356,8 @@ async def add_exp(member_id):
|
|
354 |
print(f"Creating new record for {member}")
|
355 |
|
356 |
xp = 10 # define somewhere else?
|
357 |
-
|
|
|
358 |
xp = f"L" + str(xp) + f"L"
|
359 |
member_id = str(member_id)
|
360 |
if not member_id.startswith("L") and not member_id.endswith("L"):
|
|
|
237 |
# increment the old experience value (better not to replace outright)
|
238 |
old_xp = global_df.loc[index, 'discord_exp']
|
239 |
# remove L (write, so we replace)
|
240 |
+
old_xp = str(old_xp)
|
241 |
if old_xp.startswith("L") and old_xp.endswith("L"):
|
242 |
old_xp = old_xp[1:-1]
|
243 |
# str -> int temporarily
|
244 |
new_xp = int(old_xp) + XP_PER_MESSAGE
|
245 |
# check + convert back to string + google sheet proofing
|
246 |
+
new_xp = str(new_xp)
|
247 |
+
if not new_xp.startswith("L") and not new_xp.endswith("L"):
|
248 |
new_xp = f"L" + str(new_xp) + f"L"
|
249 |
|
250 |
# add back to dataframe in memory after checking redundantly;
|
251 |
+
if new_xp.startswith("L") and new_xp.endswith("L"):
|
252 |
global_df.loc[index, 'discord_exp'] = new_xp # do not change column name
|
253 |
print(f"Record for {member} updated from {old_xp} to {global_df.loc[index, 'discord_exp']} (+{XP_PER_MESSAGE}) ")
|
254 |
|
|
|
356 |
print(f"Creating new record for {member}")
|
357 |
|
358 |
xp = 10 # define somewhere else?
|
359 |
+
xp = str(xp)
|
360 |
+
if not xp.startswith("L") and not xp.endswith("L"):
|
361 |
xp = f"L" + str(xp) + f"L"
|
362 |
member_id = str(member_id)
|
363 |
if not member_id.startswith("L") and not member_id.endswith("L"):
|