lunarflu HF staff commited on
Commit
60a6d40
·
1 Parent(s): 7aa3ae0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -22
app.py CHANGED
@@ -57,29 +57,35 @@ def calculate_xp(level):
57
  # check discord_user_id is verified
58
  # do add_exp for hub?
59
  @bot.command(name='add_exp_hub')
60
- async def add_exp_hub(ctx, discord_user_id):
61
  try:
62
- cell = worksheet2.find(str(discord_user_id))
63
- if cell.col == 5:
64
- # find hub_user_name
65
- hf_user_name = worksheet2.cell(cell.row, cell.col-2).value
66
- if hf_user_name:
67
- # check likes
68
- likes = list_liked_repos(f"{hf_user_name}")
69
- hf_likes_new = likes.total
70
- hf_likes_old = worksheet2.cell(cell.row, cell.col+2).value
71
- if hf_likes_old:
72
- hf_likes_old = int(hf_likes_old)
73
- difference = hf_likes_new - hf_likes_old
74
- if difference > 0:
75
- worksheet2.update(f'G{cell.row}', f'{hf_likes_new}')
76
- """
77
- for i in range(difference):
78
- await add_exp(discord_user_id)
79
- """
80
-
81
- else:
82
- worksheet2.update(f'G{cell.row}', f'{hf_likes_new}')
 
 
 
 
 
 
83
 
84
  except Exception as e:
85
  print(f"add_exp_hub Error: {e}")
 
57
  # check discord_user_id is verified
58
  # do add_exp for hub?
59
  @bot.command(name='add_exp_hub')
60
+ async def add_exp_hub(ctx):
61
  try:
62
+ role = discord.utils.get(guild.roles, id=900063512829755413)
63
+ if role:
64
+ # Get members with the specified role
65
+ members_with_role = [member.id for member in guild.members if role in member.roles]
66
+ for member_id in members_with_role:
67
+
68
+ cell = worksheet2.find(str(member_id))
69
+ if cell.col == 5:
70
+ # find hub_user_name
71
+ hf_user_name = worksheet2.cell(cell.row, cell.col-2).value
72
+ if hf_user_name:
73
+ # check likes
74
+ likes = list_liked_repos(f"{hf_user_name}")
75
+ hf_likes_new = likes.total
76
+ hf_likes_old = worksheet2.cell(cell.row, cell.col+2).value
77
+ if hf_likes_old:
78
+ hf_likes_old = int(hf_likes_old)
79
+ difference = hf_likes_new - hf_likes_old
80
+ if difference > 0:
81
+ worksheet2.update(f'G{cell.row}', f'{hf_likes_new}')
82
+ """
83
+ for i in range(difference):
84
+ await add_exp(discord_user_id)
85
+ """
86
+
87
+ else:
88
+ worksheet2.update(f'G{cell.row}', f'{hf_likes_new}')
89
 
90
  except Exception as e:
91
  print(f"add_exp_hub Error: {e}")