Spaces:
Runtime error
Runtime error
help command
Browse files
app.py
CHANGED
@@ -235,61 +235,68 @@ async def on_reaction_add(reaction, user):
|
|
235 |
|
236 |
@bot.command(name='update_leaderboard')
|
237 |
async def update_leaderboard(ctx, num_results: int = 10):
|
238 |
-
|
239 |
-
|
240 |
-
names_list = worksheet.col_values(2)[1:]
|
241 |
-
levels_list = worksheet.col_values(4)[1:]
|
242 |
-
exp_list = worksheet.col_values(3)[1:]
|
243 |
-
channel = bot.get_channel(1197143964994773023)
|
244 |
-
message = await channel.fetch_message(1197148293164187678)
|
245 |
-
|
246 |
-
|
247 |
-
# for 3 lists
|
248 |
-
combined_list = [list(sublist) for sublist in zip(names_list, levels_list, exp_list)]
|
249 |
-
combined_list = [[name, int(level), int(exp)] for name, level, exp in combined_list]
|
250 |
-
combined_list = sorted(combined_list, key=lambda x: x[1], reverse=True)
|
251 |
-
|
252 |
-
print(combined_list)
|
253 |
-
top_results = combined_list[:num_results]
|
254 |
-
#print(top_results)
|
255 |
-
|
256 |
-
"""
|
257 |
-
# get position, then find that value in updated_names_list
|
258 |
-
levels_list = list(map(int, levels_list))
|
259 |
-
data_pairs = list(zip(names_list, levels_list))
|
260 |
-
sorted_data_pairs = sorted(data_pairs, key=lambda x: x[1], reverse=True)
|
261 |
-
top_data_pairs = sorted_data_pairs[:num_results]
|
262 |
-
"""
|
263 |
-
|
264 |
-
|
265 |
-
# remove huggingfolks
|
266 |
-
guild = ctx.guild
|
267 |
-
role = discord.utils.get(guild.roles, id=897376942817419265)
|
268 |
-
if role is None:
|
269 |
-
await ctx.send("Role not found.")
|
270 |
-
return
|
271 |
-
members_with_role = [member.name for member in guild.members if role in member.roles]
|
272 |
-
top_results = [r for r in top_results if r[0] not in members_with_role]
|
273 |
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
288 |
|
289 |
|
290 |
|
291 |
|
|
|
|
|
|
|
|
|
292 |
|
|
|
293 |
@bot.command(name='send_message')
|
294 |
async def send_message(ctx):
|
295 |
channel = ctx.channel
|
@@ -297,6 +304,9 @@ async def send_message(ctx):
|
|
297 |
table = tabulate(leaderboard_data, headers=["User", "Score"], tablefmt="plain")
|
298 |
message = await channel.send(f"Leaderboard:\n```\n{table}\n```")
|
299 |
|
|
|
|
|
|
|
300 |
|
301 |
# embeds with user pfps?
|
302 |
# name, pfp, time in server....
|
|
|
235 |
|
236 |
@bot.command(name='update_leaderboard')
|
237 |
async def update_leaderboard(ctx, num_results: int = 10):
|
238 |
+
if ctx.author.id == 811235357663297546:
|
239 |
+
worksheet = gspread_bot.open("levelbot").sheet1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
|
241 |
+
names_list = worksheet.col_values(2)[1:]
|
242 |
+
levels_list = worksheet.col_values(4)[1:]
|
243 |
+
exp_list = worksheet.col_values(3)[1:]
|
244 |
+
channel = bot.get_channel(1197143964994773023)
|
245 |
+
message = await channel.fetch_message(1197148293164187678)
|
246 |
+
|
247 |
+
|
248 |
+
# for 3 lists
|
249 |
+
combined_list = [list(sublist) for sublist in zip(names_list, levels_list, exp_list)]
|
250 |
+
combined_list = [[name, int(level), int(exp)] for name, level, exp in combined_list]
|
251 |
+
combined_list = sorted(combined_list, key=lambda x: x[1], reverse=True)
|
252 |
+
|
253 |
+
print(combined_list)
|
254 |
+
top_results = combined_list[:num_results]
|
255 |
+
#print(top_results)
|
256 |
+
|
257 |
+
"""
|
258 |
+
# get position, then find that value in updated_names_list
|
259 |
+
levels_list = list(map(int, levels_list))
|
260 |
+
data_pairs = list(zip(names_list, levels_list))
|
261 |
+
sorted_data_pairs = sorted(data_pairs, key=lambda x: x[1], reverse=True)
|
262 |
+
top_data_pairs = sorted_data_pairs[:num_results]
|
263 |
+
"""
|
264 |
+
|
265 |
+
|
266 |
+
# remove huggingfolks
|
267 |
+
guild = ctx.guild
|
268 |
+
role = discord.utils.get(guild.roles, id=897376942817419265)
|
269 |
+
if role is None:
|
270 |
+
await ctx.send("Role not found.")
|
271 |
+
return
|
272 |
+
members_with_role = [member.name for member in guild.members if role in member.roles]
|
273 |
+
top_results = [r for r in top_results if r[0] not in members_with_role]
|
274 |
+
|
275 |
+
for name, level, xp in top_results:
|
276 |
+
print(f"Name: {name}, Level: {level}, Exp: {xp}")
|
277 |
+
|
278 |
+
|
279 |
+
def xp_required_to_next_level(current_level, current_xp):
|
280 |
+
level_floor_xp = calculate_xp(current_level)
|
281 |
+
level_ceiling_xp = calculate_xp(current_level+1)
|
282 |
+
xp_to_level_up = level_ceiling_xp - current_xp
|
283 |
+
return (xp_to_level_up)
|
284 |
+
|
285 |
+
|
286 |
+
# put into message / leaderboard
|
287 |
+
new_leaderboard_data = [(name, level, str(xp_required_to_next_level(int(level), int(xp)))) for name, level, xp in top_results]
|
288 |
+
new_table = tabulate(new_leaderboard_data, headers=["Name", "Level", "XP to level up"], tablefmt="plain")
|
289 |
+
await message.edit(content=f"Updated Leaderboard:\n```\n{new_table}\n```")
|
290 |
|
291 |
|
292 |
|
293 |
|
294 |
+
@bot.command(name='help')
|
295 |
+
async def help(ctx):
|
296 |
+
help_message = "How to earn Discord / Hub exp: Post messages, react, Like, discuss, create repos and papers"
|
297 |
+
await ctx.author.send(help_message)
|
298 |
|
299 |
+
"""
|
300 |
@bot.command(name='send_message')
|
301 |
async def send_message(ctx):
|
302 |
channel = ctx.channel
|
|
|
304 |
table = tabulate(leaderboard_data, headers=["User", "Score"], tablefmt="plain")
|
305 |
message = await channel.send(f"Leaderboard:\n```\n{table}\n```")
|
306 |
|
307 |
+
"""
|
308 |
+
|
309 |
+
|
310 |
|
311 |
# embeds with user pfps?
|
312 |
# name, pfp, time in server....
|