Skip to content

Commit

Permalink
fit: remove old exp stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
hellos3b committed Jan 30, 2024
1 parent 94c9dda commit 3ed0474
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 43 deletions.
12 changes: 4 additions & 8 deletions bot/src/commands/fit/Fit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import * as UserAuth from "./UserAuth";
import * as UserProfile from "./UserProfile";
// import * as ActivityWebhook from "./ActivityWebhook";
import * as Promotions from "./Promotions";
import * as Leaders from "./Leaders";
import * as LastActive from "./LastActive";

// @ts-ignore
Expand All @@ -30,9 +29,7 @@ const help = Format.help ({
usage: "!fit <command>",
commands: {
"auth": "Set up your strava account with the bot",
"profile": "View your progress and stats",
"leaders": "View the top 2 exp earners for each activity type",
"balance": "Check how balanced your XP"
"profile": "View your progress and stats"
}
});

Expand All @@ -45,9 +42,9 @@ const fit = Command.filtered ({
callback: message =>
match (Command.route (message))
.with ("auth", () => UserAuth.onBoarding (message))
.with ("profile", () => UserProfile.render (message))
.with ("balance", () => Balance.render (message))
.with ("leaders", () => Leaders.leaderboard (message))
.with ("profile", () => UserProfile.render(message))
.with ("balance", () => message.reply("Balance will no longer work"))
.with ("leaders", () => message.reply("Leaderboard is out of date with new scoring, will be updated"))
.with ("help", () => message.channel.send (help))
.with ("settings", () => message.reply ("Settings menu is available only in DMs"))
.with (__.nullish, () => message.channel.send (help))
Expand Down Expand Up @@ -118,5 +115,4 @@ export const routes = (client: Discord.Client) => [

export const startup = (client: Discord.Client) : void => {
LastActive.beginFlush (client);
Promotions.startSchedule (client);
};
35 changes: 0 additions & 35 deletions bot/src/commands/fit/UserProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,41 +37,6 @@ export const render = async (message: Message) : Promise<void> => {
{ name: "Rank", value: `${rank} (${score})`, inline: true },
{ name: "Total EXP", value: Format.exp (user.xp), inline: true }
]);

// All workouts in the last 30 days
const lastThirtyDays = Interval.before (DateTime.local (), { days: 30 });
const workouts = await Workout.find (Workout.during (lastThirtyDays));

// User's workouts in the last 30 days
const profileWorkouts = workouts.filter (w => w.discord_id === user.discordId);

// The start of the week, used for EXP promotion calculation
const weekStart = Week.current ().start.toUTC ();

// Collection of workouts that apply to this week's promotion
const weekly = profileWorkouts.filter (w => w.timestamp >= weekStart.toISO ());
embed.addFields ({
name: "Weekly EXP",
value: Format.exp (Workout.exp (weekly)),
inline: true
});

// The user's most recently recorded workout
const mostRecentWorkout = option (profileWorkouts)
.map (list => list.sort ((a, b) => a.timestamp > b.timestamp ? -1 : 1))
.flatMap (list => option (list[0]));

mostRecentWorkout.map (workout => {
const emoji = EmojiSet.get (workout.activity_type, workout.exp, user.emojis);
const name = workout.activity_name;
const timeAgo = fromNow (workout.timestamp, { suffix: true, max: 1 });

embed.addFields ({
name: "Last Activity",
value: `${emoji} ${name}${timeAgo}`,
inline: true
});
});

message.channel.send ({ embeds: [embed] });
};

0 comments on commit 3ed0474

Please sign in to comment.