mirror of
https://github.com/cassoule/flopobot_v2.git
synced 2026-03-18 21:40:27 +01:00
sotd win fix
This commit is contained in:
6
game.js
6
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);
|
||||
|
||||
6
index.js
6
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)
|
||||
|
||||
Reference in New Issue
Block a user