Этот код удаляет параметр на mongoDB и IDK, какой частью он является - PullRequest
0 голосов
/ 22 апреля 2020

есть параметр coins, и он существует до тех пор, пока я не выполню эту команду:

@bot.command()
async def busk(ctx):
        member = ctx.message.author.id #gets the user ID, which i use as the _id in pymongo because everyones is different.
        now = datetime.datetime.now()
        results1 = collection.find_one({"_id": member})#checks if their account exists
        results = collection.find({"_id": member})#opens to their 'account'
        if results1 == None: #if their account does not exist
                post = {"_id": member, "coins": 0, "time": 0} #create an account with their member ID as the _id
                collection.insert_one(post)#inserts the document(account) to the database.
                await ctx.send("You did not have an account, so we created one for you! try running this command again.")
        else:#If they do have an account:
                for result in results:
                        idk = result['time']
                        randomdonation = randint(1,50)
                        if idk == now.minute:
                                await ctx.send("You already used this command in the last minute!")
                        elif randomdonation == "none":#if they get the choice 'none'
                                await ctx.send("srry u get " + randomdonation)
                                db.testing.find_one_and_replace({"_id": member},{'time': now.minute})
                        else:
                                db.testing.update_one({"_id": member}, {'$inc': {"coins": randomdonation}})
                                await ctx.send(str(randomdonation) + " Coins were added to your bank!")

какая часть этого кода удаляет параметр 'coins'?

...