Files
Arthonor-Neo/commands/legacy/nuts/nutsGet.js
T
2026-04-08 11:37:01 +02:00

61 lines
1.5 KiB
JavaScript

const { mClient } = require('../../../index')
require('dotenv').config()
module.exports = {
name: 'nuts',
description: 'get nuts',
aliases: ['n', 'nget', 'nutsget'],
async execute(message, args) {
const db = mClient.db(process.env.M_DB)
const nutsColl = db.collection('items_nuts')
const nutsStatsColl = db.collection('stats_nuts')
const cdColl = db.collection('items_cooldowns')
const cdData = await cdColl.findOne({ userID: message.author.id })
if (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
})
await nutsStatsColl.findOneAndUpdate(
{ userID: message.author.id },
{ $inc: { [`stat.${amount}`]: 1 } },
{ upsert: true }
)
await nutsStatsColl.findOneAndUpdate(
{ userID: "__global" },
{ $inc: { [`stat.${amount}`]: 1 } },
{ 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
})
}
}