Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
bot.get_user more stable than guild_get member perhaps
Browse files
app.py
CHANGED
@@ -142,13 +142,14 @@ 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 |
|
149 |
guild = bot.get_guild(879548962464493619)
|
150 |
-
member =
|
151 |
-
|
152 |
lvl1 = guild.get_role(1171861537699397733)
|
153 |
lvl2 = guild.get_role(1171861595115245699)
|
154 |
lvl3 = guild.get_role(1171861626715115591)
|
@@ -220,17 +221,17 @@ async def add_exp(member_id, message):
|
|
220 |
#await member.send(f"Level up! {current_level-1} -> {current_level}!")
|
221 |
if member_id == 811235357663297546:
|
222 |
|
223 |
-
row = global_df[global_df['discord_user_id'] == str(
|
224 |
if not row.empty:
|
225 |
target_exp = row['discord_exp'].values[0]
|
226 |
rank = (global_df['discord_exp'] > target_exp).sum() + 1
|
227 |
-
print(f"The rank for discord_id {
|
228 |
else:
|
229 |
-
print(f"Discord ID {
|
230 |
|
231 |
# send embed
|
232 |
embed = Embed(color=Color.blue())
|
233 |
-
embed.set_author(name=f"{
|
234 |
embed.title = f"Level Up! `{current_level-1}` -> `{current_level}`"
|
235 |
msg = 'Congrats! You just leveled up in the Hugging Face Discord server'
|
236 |
embed.description = f"{msg}."
|
@@ -248,9 +249,9 @@ async def add_exp(member_id, message):
|
|
248 |
embed.add_field(name="Verify Here:", value=verification_link, inline=True)
|
249 |
|
250 |
|
251 |
-
lunar =
|
252 |
await lunar.send(embed=embed)
|
253 |
-
|
254 |
|
255 |
#Review the leaderboard at <link>
|
256 |
# leaderboard link
|
@@ -298,7 +299,7 @@ async def on_message(message):
|
|
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:
|
304 |
print(f"on_message Error: {e}")
|
|
|
142 |
print(f"periodic_api_test Error: {e}")
|
143 |
|
144 |
|
145 |
+
async def add_exp(member_id):
|
146 |
try:
|
147 |
+
await asyncio.sleep(0.1)
|
148 |
global global_df
|
149 |
|
150 |
guild = bot.get_guild(879548962464493619)
|
151 |
+
member = bot.get_user(member_id)
|
152 |
+
|
153 |
lvl1 = guild.get_role(1171861537699397733)
|
154 |
lvl2 = guild.get_role(1171861595115245699)
|
155 |
lvl3 = guild.get_role(1171861626715115591)
|
|
|
221 |
#await member.send(f"Level up! {current_level-1} -> {current_level}!")
|
222 |
if member_id == 811235357663297546:
|
223 |
|
224 |
+
row = global_df[global_df['discord_user_id'] == str(member_id)] # does this need to be string?
|
225 |
if not row.empty:
|
226 |
target_exp = row['discord_exp'].values[0]
|
227 |
rank = (global_df['discord_exp'] > target_exp).sum() + 1
|
228 |
+
print(f"The rank for discord_id {member_id} based on discord_exp is: {rank}")
|
229 |
else:
|
230 |
+
print(f"Discord ID {member_id} not found in the DataFrame.")
|
231 |
|
232 |
# send embed
|
233 |
embed = Embed(color=Color.blue())
|
234 |
+
embed.set_author(name=f"{member}", icon_url=member.avatar.url if member.avatar else bot.user.avatar.url)
|
235 |
embed.title = f"Level Up! `{current_level-1}` -> `{current_level}`"
|
236 |
msg = 'Congrats! You just leveled up in the Hugging Face Discord server'
|
237 |
embed.description = f"{msg}."
|
|
|
249 |
embed.add_field(name="Verify Here:", value=verification_link, inline=True)
|
250 |
|
251 |
|
252 |
+
lunar = bot.get_user(811235357663297546)
|
253 |
await lunar.send(embed=embed)
|
254 |
+
# just send all levelup messages to me for a few hours
|
255 |
|
256 |
#Review the leaderboard at <link>
|
257 |
# leaderboard link
|
|
|
299 |
if "!help_xp" not in message.content:
|
300 |
print(f"adding exp from message {message.author}")
|
301 |
await asyncio.sleep(1)
|
302 |
+
await add_exp(message.author.id)
|
303 |
await bot.process_commands(message)
|
304 |
except Exception as e:
|
305 |
print(f"on_message Error: {e}")
|