Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -230,26 +230,26 @@ async def on_reaction_add(reaction, user):
|
|
230 |
@bot.command(name='update_leaderboard')
|
231 |
async def update_leaderboard(ctx, num_pairs: int = 10):
|
232 |
worksheet = gspread_bot.open("levelbot").sheet1
|
233 |
-
# remove huggingfolks
|
234 |
-
guild = ctx.guild
|
235 |
-
role = discord.utils.get(guild.roles, id=897376942817419265)
|
236 |
-
if role is None:
|
237 |
-
await ctx.send("Role not found.")
|
238 |
-
return
|
239 |
|
240 |
-
members_with_role = [member.name for member in guild.members if role in member.roles]
|
241 |
names_list = worksheet.col_values(2)[1:]
|
242 |
-
updated_names_list = [name for name in names_list if name not in members_with_role]
|
243 |
-
|
244 |
levels_list = worksheet.col_values(4)[1:]
|
245 |
channel = bot.get_channel(1197143964994773023)
|
246 |
message = await channel.fetch_message(1197148293164187678)
|
247 |
|
248 |
# get position, then find that value in updated_names_list
|
249 |
levels_list = list(map(int, levels_list))
|
250 |
-
data_pairs = list(zip(
|
251 |
sorted_data_pairs = sorted(data_pairs, key=lambda x: x[1], reverse=True)
|
252 |
top_data_pairs = sorted_data_pairs[:num_pairs]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
253 |
|
254 |
for name, level in top_data_pairs:
|
255 |
print(f"Name: {name}, Level: {level}")
|
@@ -286,6 +286,7 @@ async def send_message(ctx):
|
|
286 |
|
287 |
# might need cell location data to pull both level and username at same time
|
288 |
# add emojis for some color
|
|
|
289 |
|
290 |
|
291 |
""""""
|
|
|
230 |
@bot.command(name='update_leaderboard')
|
231 |
async def update_leaderboard(ctx, num_pairs: int = 10):
|
232 |
worksheet = gspread_bot.open("levelbot").sheet1
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
|
|
|
234 |
names_list = worksheet.col_values(2)[1:]
|
|
|
|
|
235 |
levels_list = worksheet.col_values(4)[1:]
|
236 |
channel = bot.get_channel(1197143964994773023)
|
237 |
message = await channel.fetch_message(1197148293164187678)
|
238 |
|
239 |
# get position, then find that value in updated_names_list
|
240 |
levels_list = list(map(int, levels_list))
|
241 |
+
data_pairs = list(zip(names_list, levels_list))
|
242 |
sorted_data_pairs = sorted(data_pairs, key=lambda x: x[1], reverse=True)
|
243 |
top_data_pairs = sorted_data_pairs[:num_pairs]
|
244 |
+
|
245 |
+
# remove huggingfolks
|
246 |
+
guild = ctx.guild
|
247 |
+
role = discord.utils.get(guild.roles, id=role_id)
|
248 |
+
if role is None:
|
249 |
+
await ctx.send("Role not found.")
|
250 |
+
return
|
251 |
+
members_with_role = [member.name for member in guild.members if role in member.roles]
|
252 |
+
top_data_pairs = [pair for pair in top_data_pairs if pair[0] not in members_with_role]
|
253 |
|
254 |
for name, level in top_data_pairs:
|
255 |
print(f"Name: {name}, Level: {level}")
|
|
|
286 |
|
287 |
# might need cell location data to pull both level and username at same time
|
288 |
# add emojis for some color
|
289 |
+
# check if members are still in the server
|
290 |
|
291 |
|
292 |
""""""
|