sotd win fix

This commit is contained in:
milo
2025-07-29 00:45:14 +02:00
parent a42415048e
commit 1bc578d17d
2 changed files with 8 additions and 4 deletions

View File

@@ -657,10 +657,13 @@ export function checkWinCondition(gameState) {
export function initTodaysSOTD() {
const rankings = getAllSOTDStats.all()
const firstPlaceId = rankings > 0 ? rankings[0].user_id : null
const firstPlaceId = rankings.length > 0 ? rankings[0].user_id : null
console.log(rankings)
console.log(firstPlaceId)
if (firstPlaceId) {
const firstPlaceUser = getUser.get(firstPlaceId)
console.log(firstPlaceUser)
if (firstPlaceUser) {
updateUserCoins.run({ id: firstPlaceId, coins: firstPlaceUser.coins + 1000 });
insertLog.run({
@@ -672,6 +675,7 @@ export function initTodaysSOTD() {
user_new_amount: firstPlaceUser.coins + 1000,
})
}
console.log(`${firstPlaceId} wins ${new Date().toLocaleDateString()} SOTD`)
}
const newRandomSeed = Date.now().toString(36) + Math.random().toString(36).substr(2);

View File

@@ -558,9 +558,6 @@ client.on('messageCreate', async (message) => {
}
console.log(`Result for ${amount} skins`)
}
else if (message.content.toLowerCase().startsWith('?sotd')) {
initTodaysSOTD()
}
else if (message.author.id === process.env.DEV_ID) {
const prefix = process.env.DEV_SITE === 'true' ? 'dev' : 'flopo'
if (message.content === prefix + ':add-coins-to-users') {
@@ -575,6 +572,9 @@ client.on('messageCreate', async (message) => {
console.log(e)
}
}
else if (message.content === prefix + ':sotd') {
initTodaysSOTD()
}
else if (message.content === prefix + ':users') {
const allAkhys = getAllUsers.all()
console.log(allAkhys)