Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
passing message to add_exp so we can act based on content (testing what other member_id see)
Browse files
app.py
CHANGED
|
@@ -142,7 +142,7 @@ async def periodic_api_test(): # needs rewrite, can do same thing and interact w
|
|
| 142 |
print(f"periodic_api_test Error: {e}")
|
| 143 |
|
| 144 |
|
| 145 |
-
async def add_exp(member_id):
|
| 146 |
try:
|
| 147 |
global global_df
|
| 148 |
|
|
@@ -218,13 +218,13 @@ async def add_exp(member_id):
|
|
| 218 |
if current_role in member.roles: # needs update; reference exp reward for verification
|
| 219 |
#await member.send(f"Level up! {current_level-1} -> {current_level}!")
|
| 220 |
if member_id == 811235357663297546:
|
| 221 |
-
row = global_df[global_df['discord_user_id'] == str(
|
| 222 |
if not row.empty:
|
| 223 |
target_exp = row['discord_exp'].values[0]
|
| 224 |
rank = (global_df['discord_exp'] > target_exp).sum() + 1
|
| 225 |
-
print(f"The rank for discord_id {
|
| 226 |
else:
|
| 227 |
-
print(f"Discord ID {
|
| 228 |
|
| 229 |
# send embed
|
| 230 |
embed = Embed(color=Color.blue())
|
|
@@ -232,13 +232,19 @@ async def add_exp(member_id):
|
|
| 232 |
embed.title = f"Level Up! `{current_level-1}` -> `{current_level}`"
|
| 233 |
msg = 'Congrats! You just leveled up in the Hugging Face Discord server'
|
| 234 |
embed.description = f"{msg}."
|
| 235 |
-
embed.add_field(name="Leaderboard Ranking:", value=f"
|
| 236 |
-
msg3 = "- Posting \n - Reacting \n - Being active on the Hugging Face Hub (verify to link your Hub + Discord accounts!)"
|
| 237 |
-
embed.add_field(name="Continue Leveling Up by:", value=msg3, inline=True)
|
| 238 |
-
verification_link = "https://discord.com/channels/879548962464493619/900125909984624713"
|
| 239 |
-
embed.add_field(name="Verify Here:", value=verification_link, inline=True)
|
| 240 |
# can use ^ to track changes in leaderboard ranking and display in levelup message when climbing
|
| 241 |
# (green red arrow thingies)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
|
| 243 |
lunar = guild.get_member(811235357663297546)
|
| 244 |
await lunar.send(embed=embed)
|
|
@@ -288,7 +294,7 @@ async def on_message(message):
|
|
| 288 |
if "!help_xp" not in message.content:
|
| 289 |
print(f"adding exp from message {message.author}")
|
| 290 |
await asyncio.sleep(1)
|
| 291 |
-
await add_exp(message.author.id)
|
| 292 |
await bot.process_commands(message)
|
| 293 |
except Exception as e:
|
| 294 |
print(f"on_message Error: {e}")
|
|
|
|
| 142 |
print(f"periodic_api_test Error: {e}")
|
| 143 |
|
| 144 |
|
| 145 |
+
async def add_exp(member_id, message):
|
| 146 |
try:
|
| 147 |
global global_df
|
| 148 |
|
|
|
|
| 218 |
if current_role in member.roles: # needs update; reference exp reward for verification
|
| 219 |
#await member.send(f"Level up! {current_level-1} -> {current_level}!")
|
| 220 |
if member_id == 811235357663297546:
|
| 221 |
+
row = global_df[global_df['discord_user_id'] == str(message.content)] # does this need to be string?
|
| 222 |
if not row.empty:
|
| 223 |
target_exp = row['discord_exp'].values[0]
|
| 224 |
rank = (global_df['discord_exp'] > target_exp).sum() + 1
|
| 225 |
+
print(f"The rank for discord_id {message.content} based on discord_exp is: {rank}")
|
| 226 |
else:
|
| 227 |
+
print(f"Discord ID {message.content} not found in the DataFrame.")
|
| 228 |
|
| 229 |
# send embed
|
| 230 |
embed = Embed(color=Color.blue())
|
|
|
|
| 232 |
embed.title = f"Level Up! `{current_level-1}` -> `{current_level}`"
|
| 233 |
msg = 'Congrats! You just leveled up in the Hugging Face Discord server'
|
| 234 |
embed.description = f"{msg}."
|
| 235 |
+
embed.add_field(name="Leaderboard Ranking:", value=f"👑**{rank}**", inline=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
# can use ^ to track changes in leaderboard ranking and display in levelup message when climbing
|
| 237 |
# (green red arrow thingies)
|
| 238 |
+
# could also pull ranks above and below yourself (if they exist, i.e.)
|
| 239 |
+
# 1 nateraw
|
| 240 |
+
# 2 [you are here]
|
| 241 |
+
# 3 osanseviero
|
| 242 |
+
# also, ahead by how much exp, how many levels maybe
|
| 243 |
+
msg3 = "- Posting \n Reacting / being reacted to \n Being active on the Hugging Face Hub (verify to link your Hub + Discord accounts!)"
|
| 244 |
+
embed.add_field(name="How to Level Up:", value=msg3, inline=True)
|
| 245 |
+
verification_link = "https://discord.com/channels/879548962464493619/900125909984624713"
|
| 246 |
+
embed.add_field(name="Verify Here:", value=verification_link, inline=True)
|
| 247 |
+
|
| 248 |
|
| 249 |
lunar = guild.get_member(811235357663297546)
|
| 250 |
await lunar.send(embed=embed)
|
|
|
|
| 294 |
if "!help_xp" not in message.content:
|
| 295 |
print(f"adding exp from message {message.author}")
|
| 296 |
await asyncio.sleep(1)
|
| 297 |
+
await add_exp(message.author.id, message)
|
| 298 |
await bot.process_commands(message)
|
| 299 |
except Exception as e:
|
| 300 |
print(f"on_message Error: {e}")
|