CALORIE SYSTEM
This commit is contained in:
21
commands.py
21
commands.py
@@ -1,7 +1,7 @@
|
||||
import discord
|
||||
from discord import app_commands
|
||||
from db import get_db
|
||||
from constants import VALORANT_RANKS, WORKOUTS
|
||||
from constants import VALORANT_RANKS, WORKOUTS, WORKOUT_CALORIES
|
||||
from helpers import apply_rr
|
||||
import random
|
||||
|
||||
@@ -52,7 +52,7 @@ def register(tree: app_commands.CommandTree):
|
||||
for name in ENABLED_WORKOUTS.keys()
|
||||
]
|
||||
|
||||
@tree.command(name="match_temp", description="Log a Valorant match")
|
||||
@tree.command(name="match", description="Log a Valorant match")
|
||||
@app_commands.describe(
|
||||
result="Match result",
|
||||
rr_change="RR gained or lost",
|
||||
@@ -128,11 +128,16 @@ def register(tree: app_commands.CommandTree):
|
||||
|
||||
bonus_text = " (+10 loss penalty)" if result == "LOSS" else ""
|
||||
|
||||
# Calculate calories burned
|
||||
cal_per_rep = WORKOUT_CALORIES.get(workout, 0)
|
||||
calories_burned = round(workout_total * cal_per_rep, 2)
|
||||
|
||||
await interaction.response.send_message(
|
||||
f"🏆 Match logged\n"
|
||||
f"**Result:** {result}\n"
|
||||
f"**Rank:** {new_rank} ({new_rr} RR)\n"
|
||||
f"**Workout:** {workout} × {workout_total}{bonus_text}"
|
||||
f"**Workout:** {workout} × {workout_total}{bonus_text}\n"
|
||||
f"**Calories:** {calories_burned:.1f} Cal"
|
||||
)
|
||||
|
||||
cur.execute("""
|
||||
@@ -141,9 +146,10 @@ def register(tree: app_commands.CommandTree):
|
||||
kills = kills + %s,
|
||||
deaths = deaths + %s,
|
||||
rank = %s,
|
||||
rr = %s
|
||||
rr = %s,
|
||||
calories_burned = calories_burned + %s
|
||||
WHERE discord_id = %s
|
||||
""", (kills, deaths, new_rank, new_rr, str(interaction.user.id)))
|
||||
""", (kills, deaths, new_rank, new_rr, float(calories_burned), str(interaction.user.id)))
|
||||
|
||||
cur.execute("""
|
||||
INSERT INTO workouts (discord_id, workout, amount)
|
||||
@@ -212,6 +218,11 @@ def register(tree: app_commands.CommandTree):
|
||||
value=f"{u['kills']} / {u['deaths']}",
|
||||
inline=False
|
||||
)
|
||||
embed.add_field(
|
||||
name="Calories Burned",
|
||||
value=f"{u.get('calories_burned', 0):.1f} Cal",
|
||||
inline=False
|
||||
)
|
||||
|
||||
workout_text = (
|
||||
"\n".join(f"{w['workout']}: {w['amount']}" for w in workout_rows)
|
||||
|
||||
Reference in New Issue
Block a user