added nut context to cooldown
This commit is contained in:
@@ -11,37 +11,40 @@ module.exports = {
|
||||
|
||||
const cdData = await cdColl.findOne({ userID: message.author.id })
|
||||
|
||||
if (!cdData || cdData.cooldown < (Date.now() / 1000)) {
|
||||
let cd = Math.floor((Date.now() + 3600000) / 1000)
|
||||
await cdColl.findOneAndUpdate({
|
||||
userID: message.author.id
|
||||
}, {
|
||||
$set: { cooldown: cd }
|
||||
}, {
|
||||
upsert: true
|
||||
})
|
||||
|
||||
const amount = Math.floor(Math.random() * 10)
|
||||
|
||||
await nutsColl.findOneAndUpdate({
|
||||
userID: message.author.id
|
||||
}, {
|
||||
$inc: { nuts: amount }
|
||||
}, {
|
||||
upsert: true
|
||||
})
|
||||
|
||||
let content = `Du hast ${amount} Nüsse bekommen! :chestnut:`
|
||||
if (!amount) {
|
||||
content = `Du hast leider keine Nüsse bekommen :(`
|
||||
}
|
||||
return await message.reply({
|
||||
content: content
|
||||
})
|
||||
} else {
|
||||
if (cdData || cdData?.cooldown > (Date.now() / 1000)) {
|
||||
return await message.reply({
|
||||
content: `Du kannst erst <t:${Math.floor(cdData?.cooldown)}:R> wieder nussen :(`,
|
||||
})
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
let cd = Math.floor((Date.now() + 3600000) / 1000)
|
||||
await cdColl.findOneAndUpdate({
|
||||
userID: message.author.id
|
||||
}, {
|
||||
$set: {
|
||||
cooldown: cd,
|
||||
application: 'nuts'
|
||||
}
|
||||
}, {
|
||||
upsert: true
|
||||
})
|
||||
|
||||
const amount = Math.floor(Math.random() * 10)
|
||||
|
||||
await nutsColl.findOneAndUpdate({
|
||||
userID: message.author.id
|
||||
}, {
|
||||
$inc: { nuts: amount }
|
||||
}, {
|
||||
upsert: true
|
||||
})
|
||||
|
||||
let content = `Du hast ${amount} Nüsse bekommen! :chestnut:`
|
||||
if (!amount) {
|
||||
content = `Du hast leider keine Nüsse bekommen :(`
|
||||
}
|
||||
return await message.reply({
|
||||
content: content
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user