【发布时间】:2021-05-27 19:59:54
【问题描述】:
我正在尝试用 python 制作我的第一个 discord 机器人,它是一个经济型机器人,但它说我不能使用 await 函数,我不知道为什么。
@bot.command()
async def withdraw(ctx,amount = None):
await open_account(ctx.author)
if amount == None:
await ctx.send("Please enter a valid amount")
return
bal = await update_bank(ctx.author)
amount = int(amount)
if amount>bal[1]:
await ctx.send("You don't have enough potatoes!")
return
if amount<0:
await ctx.send("Can only send positive potatoes! No negative!")
return
await update_bank(ctx.author,amount)
await update_bank(ctx.author,-1*amount, "bank")
await ctx.send(f"You withdrew {amount} potatoes!")
【问题讨论】:
-
如果这是 discord.rewritten,那么要么不要使用 async,要么确保你使用的是正确的 python 版本。
标签: python discord discord.py