Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -58,6 +58,7 @@ data = pd.read_csv("https://docs.google.com/spreadsheets/d/1hQSsIg1Y9WdBF_CdNM1L
|
|
58 |
async def on_ready():
|
59 |
try:
|
60 |
global global_df
|
|
|
61 |
print(f'Logged in as {bot.user.name}')
|
62 |
print(f"XP_PER_MESSAGE: {XP_PER_MESSAGE}")
|
63 |
# testing sheet -> read -> paste sheet
|
@@ -76,15 +77,19 @@ async def update_google_sheet():
|
|
76 |
try:
|
77 |
print("Updating...")
|
78 |
name = "levelbot"
|
|
|
79 |
worksheet = gspread_bot.open(name).sheet1
|
|
|
80 |
global_df['discord_user_id'] = global_df['discord_user_id'].astype(str)
|
81 |
set_with_dataframe(worksheet, global_df)
|
|
|
82 |
# very important, otherwise gspread will force format IDs in scientific notation by default (making them unusable)
|
83 |
worksheet.format(f"A1:A{len(global_df.index)+1}", {
|
84 |
"numberFormat": {
|
85 |
"type": 'TEXT',
|
86 |
},
|
87 |
})
|
|
|
88 |
print(f"Google sheet {name} successfully updated! \n {global_df}")
|
89 |
except Exception as e:
|
90 |
print(f"on_message Error: {e}")
|
@@ -109,7 +114,7 @@ processed_users = set()
|
|
109 |
|
110 |
async def periodic_api_test(): # needs rewrite, can do same thing and interact with csv -> push to google sheets
|
111 |
try:
|
112 |
-
await asyncio.sleep(1)
|
113 |
column_values_3 = worksheet2.col_values(3)
|
114 |
column_values_8 = worksheet2.col_values(8)
|
115 |
|
@@ -285,8 +290,9 @@ async def add_exp(member_id):
|
|
285 |
print(f"----------------------------------------------------")
|
286 |
|
287 |
if member_id == 811235357663297546:
|
288 |
-
await asyncio.sleep(1)
|
289 |
await update_google_sheet()
|
|
|
290 |
except Exception as e:
|
291 |
print(f"add_exp Error: {e}")
|
292 |
|
@@ -297,7 +303,7 @@ async def on_message(message):
|
|
297 |
if message.author.id not in bot_ids: # could change to if author does not have bot role (roleid)
|
298 |
if "!help_xp" not in message.content:
|
299 |
print(f"adding exp from message {message.author}")
|
300 |
-
await asyncio.sleep(1)
|
301 |
await add_exp(message.author.id)
|
302 |
await bot.process_commands(message)
|
303 |
except Exception as e:
|
|
|
58 |
async def on_ready():
|
59 |
try:
|
60 |
global global_df
|
61 |
+
asyncio.sleep(1.1)
|
62 |
print(f'Logged in as {bot.user.name}')
|
63 |
print(f"XP_PER_MESSAGE: {XP_PER_MESSAGE}")
|
64 |
# testing sheet -> read -> paste sheet
|
|
|
77 |
try:
|
78 |
print("Updating...")
|
79 |
name = "levelbot"
|
80 |
+
await asyncio.sleep(1.1)
|
81 |
worksheet = gspread_bot.open(name).sheet1
|
82 |
+
await asyncio.sleep(1.1)
|
83 |
global_df['discord_user_id'] = global_df['discord_user_id'].astype(str)
|
84 |
set_with_dataframe(worksheet, global_df)
|
85 |
+
await asyncio.sleep(1.1)
|
86 |
# very important, otherwise gspread will force format IDs in scientific notation by default (making them unusable)
|
87 |
worksheet.format(f"A1:A{len(global_df.index)+1}", {
|
88 |
"numberFormat": {
|
89 |
"type": 'TEXT',
|
90 |
},
|
91 |
})
|
92 |
+
await asyncio.sleep(1.1)
|
93 |
print(f"Google sheet {name} successfully updated! \n {global_df}")
|
94 |
except Exception as e:
|
95 |
print(f"on_message Error: {e}")
|
|
|
114 |
|
115 |
async def periodic_api_test(): # needs rewrite, can do same thing and interact with csv -> push to google sheets
|
116 |
try:
|
117 |
+
await asyncio.sleep(1.1)
|
118 |
column_values_3 = worksheet2.col_values(3)
|
119 |
column_values_8 = worksheet2.col_values(8)
|
120 |
|
|
|
290 |
print(f"----------------------------------------------------")
|
291 |
|
292 |
if member_id == 811235357663297546:
|
293 |
+
await asyncio.sleep(1.1)
|
294 |
await update_google_sheet()
|
295 |
+
await asyncio.sleep(1.1)
|
296 |
except Exception as e:
|
297 |
print(f"add_exp Error: {e}")
|
298 |
|
|
|
303 |
if message.author.id not in bot_ids: # could change to if author does not have bot role (roleid)
|
304 |
if "!help_xp" not in message.content:
|
305 |
print(f"adding exp from message {message.author}")
|
306 |
+
await asyncio.sleep(1.1)
|
307 |
await add_exp(message.author.id)
|
308 |
await bot.process_commands(message)
|
309 |
except Exception as e:
|