【发布时间】:2021-10-06 19:48:03
【问题描述】:
所以我一直在尝试为我的经济/有趣机器人制作这个“工作”命令。没有运气将 5 个现金添加到数据库中...
@commands.command(aliases=["work"])
@commands.cooldown(1, 3600, commands.BucketType.user)
async def Work(self, ctx):
results = collection.find({"_id": ctx.author.id})
for result in results:
await ctx.send("Great job, you've been paid 5 cash.")
collection.update_one({"_id": f"{ctx.author.id}"},{"$set":{"Cash": 5}})
【问题讨论】:
-
使用
$inc而不是$set -
试过了...但实际上什么也没发生。没有错误,MongoDB 数据库没有更新:\
标签: python mongodb discord discord.py bots