decomplicate vote reward code + fix vote streak being incorrect
@@ -87,34 +87,35 @@ class Webhooks(commands.Cog):
self.bot.logger.info(f'\u001b[32;1m{uid} voted on top.gg\u001b[0m')
self.d.votes_topgg += 1
- amount = self.d.topgg_reward * self.d.base_multi
+ amount = self.d.topgg_reward
if data.isWeekend:
- amount *= self.d.weekend_multi
+ amount *= 2
- amount *= len(self.d.mining.pickaxes) - self.d.mining.pickaxes.index(await self.db.fetch_pickaxe(int(data.user)))
+ amount *= len(self.d.mining.pickaxes) - self.d.mining.pickaxes.index(await self.db.fetch_pickaxe(uid))
db_user = await self.db.fetch_user(uid)
streak_time = db_user['streak_time']
vote_streak = db_user['vote_streak']
+ if vote_streak is None or vote_streak is 0:
+ vote_streak = 0
+
+ vote_streak += 1
+
if streak_time is None: # time
streak_time = 0
if arrow.utcnow().shift(days=-1) > arrow.get(streak_time): # vote expired
- vote_streak = 0
-
- vote_streak_extra = (5 if vote_streak > 5 else vote_streak)
- if vote_streak_extra < 1:
- vote_streak_extra = 1
+ vote_streak = 1
- amount *= vote_streak_extra
+ amount *= (5 if vote_streak > 5 else vote_streak)
await self.db.update_user(uid, 'streak_time', arrow.utcnow().timestamp)
- await self.db.update_user(uid, 'vote_streak', vote_streak+1)
+ await self.db.update_user(uid, 'vote_streak', vote_streak)
- await self.reward(uid, amount, vote_streak+1)
+ await self.reward(uid, amount, vote_streak)
def setup(bot):
