这是我的“日常”命令。我希望连接 mongo,以便它检测用户是否在之前使用过该命令的 24 小时内使用过该命令。
const _50 = '50'
const _100 = '100'
const _500 = '500'
const _1000 = '1000'
let money = chance.weighted([_50, _100, _500, _1000], [.80, .10, .05, .02]);
const profileData = await Profiles.findOne({ userID: message.author.id });
if(!profileData) return message.channel.send('Your account is not yet registered, please do `!register` to register.');
if(!profileData.moneyCount >= 0.00) {
await Profiles.findOneAndUpdate(
{
userID: message.author.id,
},
{
$inc: { moneyCount: money }
},
)
message.reply(`$${money} has been added to your account!`);
}
这是我的架构,如果可能,我想使用时间戳:
{
"_id": {
"$oid": "605e97bbd4af3e454c26131c"
},
"Skins": [16978],
"userID": "375697909787787267",
"messageCount": 0,
"caseCount": 0,
"moneyCount": 10,
"createdAt": {
"$date": "2021-03-27T02:26:03.873Z"
},
"updatedAt": {
"$date": "2021-03-27T02:26:03.873Z"
},
"__v": 0
}