运行时警告:协程'update_bank'从未等待 ret = await coro(*args, **kwargs) 运行时警告:启用 tracemalloc



我不知道我做错了什么得到这个错误…既然我一直在等待那些应该等待的事情,除非我没有等待,而且我似乎看不到它?虽然它说它是在更新银行功能时,我甚至没有使用它,这个错误只发生在使用这个命令。

代码如下:

async def use_this(user,item_name,amount,price = None):
item_name = item_name.lower()
name_ = None
for item in mainshop:
name = item["name"].lower()
if name == item_name:
name_ = name
if price==None:
price = 0* item["price"]
break
if name_ == None:
return [False,1]
cost = price*amount
users = await get_bank_data()
bal = await update_bank(user)

try:
index = 0
t = None
for thing in users[str(user.id)]["bag"]:
n = thing["item"]
if n == item_name:
old_amt = thing["amount"]
new_amt = old_amt - amount
if new_amt < 0:
return [False,2]
users[str(user.id)]["bag"][index]["amount"] = new_amt
t = 1
break
index+=1 
if t == None:
return [False,3]
except:
return [False,3]    
with open("mainbank.json","w") as f:
json.dump(users,f)
await update_bank(user,cost,"wallet")
return [True,"Worked"]

@client.command()
async def hunt(ctx,item = ['rifle','Rifle'],amount = 1):
user = ctx.author
users = await get_bank_data()
res = await use_this(ctx.author,item,amount)

rifle = "rifle"
if amount > 1:
await ctx.reply("You cant use multiple rifles,it would be too heavy for you!")
elif item == "rifle":
res = await use_this(ctx.author,item,amount)
if not res[0]:
if res[1]==1:
await ctx.reply(f"{ctx.author.mention} That Object isn't there!")
return
if res[1]==2:
await ctx.reply(f"{ctx.author.mention} You don't have {amount} {item} in your bag.")
return
if res[1]==3:
await ctx.reply(f"{ctx.author.mention} You don't have {item} in your bag.")
return
aninames = ['bear','rabbit','wolf']
animals = random.choice(aninames)
earnings = random.randrange(5000)
await ctx.reply(f"You used hunted {animals} for {earnings} coins!,you lost the rifle in the process tho ..")```

试着做

import tracemalloc
tracemalloc.start()

,那么您应该得到完整的回溯这样更容易帮助你

需要将await添加到update_bank

所以这样做:

await update_bank(...)

注:需要什么就放什么,比如ctx。作者在里面。

当你看到这个

update_bank(...)

相关内容

最新更新