lunarflu HF staff commited on
Commit
33b6465
·
verified ·
1 Parent(s): a847ba7

safeguards for bot (dm exp, self react exp)

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -636,10 +636,12 @@ async def on_reaction_add(reaction, user):
636
  try:
637
  if user.id not in bot_ids:
638
  print(f"adding exp from react {user}")
639
- await asyncio.sleep(0.1)
640
- await add_exp(user.id)
 
641
  await asyncio.sleep(0.1)
642
- await add_exp(reaction.message.author.id)
 
643
  except Exception as e:
644
  print(f"on_reaction_add Error: {e}")
645
 
 
636
  try:
637
  if user.id not in bot_ids:
638
  print(f"adding exp from react {user}")
639
+ await asyncio.sleep(0.1)
640
+ if not isinstance(message.channel, discord.DMChannel): # can't earn exp from DMing the bot, which is harder to track
641
+ await add_exp(user.id)
642
  await asyncio.sleep(0.1)
643
+ if reaction.message.author.id != user.id: # can't earn while self-reacting, which is abuseable
644
+ await add_exp(reaction.message.author.id)
645
  except Exception as e:
646
  print(f"on_reaction_add Error: {e}")
647