diff --git a/game.js b/game.js index 9132bd3..0b70b06 100644 --- a/game.js +++ b/game.js @@ -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); diff --git a/index.js b/index.js index 35e60dd..a904576 100644 --- a/index.js +++ b/index.js @@ -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)