Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gc committed Jul 19, 2024
1 parent ae37b53 commit dc5da88
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ client.once('ready', () => onStartup());
async function main() {
if (process.env.TEST) return;
await Promise.all([
runTimedLoggedFn('Sync Active User IDs', syncActiveUserIDs),
syncActiveUserIDs(),
runTimedLoggedFn('Sync Activity Cache', syncActivityCache),
runTimedLoggedFn('Startup Scripts', runStartupScripts),
runTimedLoggedFn('Sync Disabled Commands', syncDisabledCommands),
Expand Down
10 changes: 7 additions & 3 deletions src/mahoji/mahojiSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,19 @@ export async function userStatsUpdate<T extends Prisma.UserStatsSelect = Prisma.
})) as SelectedUserStats<T>;
}

export async function userStatsBankUpdate(user: MUser, key: JsonKeys<UserStats>, bank: Bank) {
export async function userStatsBankUpdate(user: MUser | string, key: JsonKeys<UserStats>, bank: Bank) {
if (!key) throw new Error('No key provided to userStatsBankUpdate');
const stats = await user.fetchStats({ [key]: true });
const userID = typeof user === 'string' ? user : user.id;
const stats =
typeof user === 'string'
? await fetchUserStats(userID, { [key]: true })
: await user.fetchStats({ [key]: true });
const currentItemBank = stats[key] as ItemBank;
if (!isObject(currentItemBank)) {
throw new Error(`Key ${key} is not an object.`);
}
await userStatsUpdate(
user.id,
userID,
{
[key]: bank.clone().add(currentItemBank).bank
},
Expand Down

0 comments on commit dc5da88

Please sign in to comment.